The name and suffix name encountered when downloading pictures with streaming
public String getObject() throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException, InvalidArgumentException {
HttpServletRequest request = ServletActionContext.getRequest();
fName = request.getParameter("fName");
String wxin = ConfigInfo.getPropertiesValue("s3.bucket");
byte[] str = Minoperator.getObject(wxin, imgurl);
fileNameFileName = fName;
logger.info("Picture upload ===============fName"+fName);
logger.info("Picture upload =============bluckname"+bluckname);
HttpServletResponse response = null;
ServletOutputStream out = null;
try {
response = ServletActionContext.getResponse();
response.setContentType("multipart/form-data");
//2. Set the file header: The last parameter is to set the download file name (if we call it a.pdf), to prevent the browser from downloading without a file name, the suffix name is the method name
response.setHeader("Content-Disposition", "attachment;fileName="+imgurl);
out = response.getOutputStream();
out.write(str);
// Prevent the incomplete stream caused by closing the stream without committing out.close ()
out.flush();
} catch (Exception e) {
e.printStackTrace ();
} finally {
if (out != null) {
try {
out.close();
} catch (Exception e) {
e.printStackTrace ();
}
}
if (response != null) {
try {
response.flushBuffer();
} catch (Exception e) {
e.printStackTrace ();
}
}
}
return null;
}