Unsolved
This post is more than 5 years old
1 Message
0
1290
how to set CONTENT_DISPOSITION use ecs-sdk
I wrote some code to get the filename when do getObject , but i got some error.
here is my code and some other message
String oID = UUID.randomUUID().toString();
//上传文件
InputStream in = new FileInputStream(tempFile);
PutObjectRequest ob = new PutObjectRequest(bucketName, oID, in);
PutObjectResult rlt = s3.putObject(ob);
System.out.println("上传完成!FileName = "+oID+", File_etag = "+rlt.getETag());
PresignedUrlRequest urlRequest = new PresignedUrlRequest(Method.GET, bucketName, oID
, new Date(System.currentTimeMillis()+365*24*3600*1000));
urlRequest.headerOverride(ResponseHeaderOverride.CONTENT_DISPOSITION, "attachment;filename=bame.xlsx;")
System.out.println(s3.getPresignedUrl(urlRequest).toString());
i run that code and got a url like :
i copy this url to The Chrome browser ,i got a file named 95e5fb06-51b0-406e-8e60-848db7e7dbf4 but bame.xlsx.
here is the caught
GET /testbucket/95e5fb06-51b0-406e-8e60-848db7e7dbf4?AWSAccessKeyId=test&Expires=1525685094&Signature=zs9D%2BXxvocnArX62yW%2FplGV7cFw%3D&response-content-disposition=attachment%3Bfilename%3Dbame.xlsx%3B HTTP/1.1
Host: 172.16.80.175:9020
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,ca;q=0.7
Cookie: GsGuideLastState=dismissed; GsGuideStep=buckets; XSRF-TOKEN=59821f2424a653a5a272caf4cdfe7c44
HTTP/1.1 200 OK
Date: Fri, 20 Apr 2018 08:45:06 GMT
Server: ViPR/1.0
x-amz-request-id: ac1050af:15f73c3deb8:19c:a
Expires: 1525685094
x-amz-id-2: b81ee199d2f77da905f709aaae5479ad3a70131ee5940b0184a82548b0de7a9b
ETag: "d7862759f93e69274008fbdba6580ebb"
Last-Modified: Fri, 20 Apr 2018 08:44:12 GMT
x-emc-mtime: 1524213852263
Content-Encoding: identity
Content-Disposition: attachment%3Bfilename%3Dbame.xlsx%3B
Content-Type: application/octet-stream
Content-Length: 9
filename
sincerely get some suggestions,Thkans
benschumacher
75 Posts
0
April 27th, 2018 12:00
What version of ECS are you testing this with? There was a bug in ECS where the value in Content-Disposition was being returned UrlEncoded. This was fixed in ECS 3.1. I don't see anything wrong with your code. Can you register for an ECS Test Drive account and test on that ECS which is running 3.2? You can register at portal.ecstestdrive.com. Please let me know if you continue to have issues.
Ben