普通人需要每天喝牛奶吗(成年人还要每天喝牛奶吗)
605 2022-09-30 03:56:34
1前端注意点:
a.*.v
b..api.js
*.js
2.后端通过取得的url,下载文件到固定文件夹
3.运行
4.下载码:
try{
//*********************url************************
response1.reset();
//response1.setContentType(" *** lication/x-msdownload");
response1.setHeader("contentDisposition","attachment;filename-"+ new String(filename.getBytes("gb2312"),"ISO8859-1"));
OSS ossClient = new OSSClientBuilder().build(ossendpoint, stsaccessKeyId, stsaccessKeySecret, stssecurityToken);
String objectName="upload/test/"+filename;
OSSObject object =ossClient.getObject(bucketName,objectName);
BufferedInputStream input =new BufferedInputStream(object.getObjectContent());
byte[] buffBytes =new byte[1024];
//OutputStream outputStream=response1.getOutputStream();
BufferedOutputStream outputStream=new BufferedOutputStream(new FileOutputStream(new File("d:/OSS/"+filename)));
int read=0;
while((read =input.read(buffBytes))!=-1) {
System.out.println("========");
outputStream.write(buffBytes,0,read);
}
outputStream.flush();
outputStream.close();//is.close();
input.close();
// 关闭OSSClient。
ossClient.shutdown();
} catch (Exception e) {
System.out.println("Failed:");
System.out.println("Error code: " + e.getMessage());
}