简体   繁体   English

从AWS下载带有特殊字符“:”的文件

[英]Download file with special character “:” from AWS

I have some trouble with downloading the above file from aws. 我从aws下载上述文件时遇到了一些麻烦。 I tried to download this file by CouldBerry Explore and Java, but I failed. 我尝试通过CouldBerry Explore和Java下载此文件,但失败了。 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 ":"? aws文档说我需要特殊处理。( https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html )因此,您能告诉我如何使用“:”处理下载此文件。 ?

The following is my file infomation. 以下是我的文件信息。

File name:"E:\\Home\\temp\\test-1_20180101.csv" 文件名:“ E:\\ Home \\ temp \\ test-1_20180101.csv”

Object key:"testaws/data/E:\\Home\\temp\\test-1_20180101.csv" 对象键:“ 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." 当我尝试通过CouldBerry Explore下载文件时,ettro消息为“我们计算出的请求签名与您提供的签名不匹配。请检查您的密钥和签名方法。”

And I show you Java codes to download file 我向您展示了Java代码来下载文件

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. 我在Mac上使用AWS命令行界面(CLI)对此进行了测试,并成功地成功上传/下载了具有该名称的文件。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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