简体   繁体   中英

Download file with special character “:” from AWS

I have some trouble with downloading the above file from aws. I tried to download this file by CouldBerry Explore and Java, but I failed. The aws document says that I need require special handling.( https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html ) So, could you tell me how to handle downloading this file with ":"?

The following is my file infomation.

File name:"E:\\Home\\temp\\test-1_20180101.csv"

Object key:"testaws/data/E:\\Home\\temp\\test-1_20180101.csv"

When I tried to download file by CouldBerry Explore, the ettro message is "The request Signature we calculated does not match the signature you provided. Check your key and signing method."

And I show you Java codes to download file

import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3ObjectSummary;

...
String prefix ="testaws/data/"
ListObjectsRequest request = new ListObjectsRequest().withBucketName(MY_BUCKET_NAME).withPrefix(prefix).withDelimiter("/");
ObjectListing list = s3.listObjects(request);
List<S3ObjectSummary> summary = list.getObjectSummaries();
...

summary contains nothing, so it seems to fail to downloading file. (Obviously, I successfully download file without ":")

I tested this using the AWS Command-Line Interface (CLI) on a Mac and successfully managed to upload/download a file with that name. However, I had to quote the name so that the backslashes were not interpreted as escape characters:

aws s3 cp "s3://my-bucket/testaws/data/E:\Home\temp\test-1_20180101.csv" test.csv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM