【问题标题】:Send folder to s3 bucket, but do not copy the folder structure将文件夹发送到 s3 存储桶,但不要复制文件夹结构
【发布时间】:2020-06-03 14:37:26
【问题描述】:

我想向亚马逊发送一个递归文件夹。

文件夹: 文件夹

└───FOLDER
    ├───SUBFOLDER
            |
            |__ file1.jpg
            |
            |__ file2.jpg
    ├───SUBFOLDER(2)
            |
            |__ file3.jpg
            |
            |__ file4.jpg

为此用途:

asw s3 cp /folder s3://mybucket/folder_destination --recursive

但是到达bucket中的bucket中的文件夹结构相同。

我的愿望是它到达具有这种结构的存储桶:

└───BUCKET
        ├───folder_destination
                |
                |__ file1.jpg
                |
                |__ file2.jpg
                |
                |__ file3.jpg
                |
                |__ file4.jpg

我测试了这个球棒:

pushd C:\Users\user\Desktop\FOLDER
for /r %%a in (*.jpg) do (
       aws s3 cp  "%%a" "s3://bucket/Test/%%~nxa"
   )
   popd

他做我想做的事,但速度很慢。

for (File f : arquivos) {
            System.out.println(f);
            String fileObjKeyName = "Test" + f.toString().split("/")[f.toString().split("/").length - 1];


            PutObjectRequest request = new PutObjectRequest(bucketName, fileObjKeyName, f);
            ObjectMetadata metadata = new ObjectMetadata();
            metadata.setContentType("image/jpeg");
            //metadata.addUserMetadata("title", "someTitle");
            request.setMetadata(metadata);
            s3Client.putObject(request);
        }

太慢了

有没有什么方法可以在没有文件夹结构的情况下快速发送它们?

【问题讨论】:

    标签: java amazon-web-services batch-file amazon-s3


    【解决方案1】:

    最快和最简单的方法是首先将多个子文件夹中的所有单个文件复制到一个新的临时文件夹,然后 aws s3 sync 该文件夹直到 S3,然后擦除临时文件夹。

    或者你可以run commands concurrently

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-20
      • 1970-01-01
      • 2014-08-05
      • 2018-09-04
      • 2015-05-20
      • 1970-01-01
      • 1970-01-01
      • 2019-10-30
      相关资源
      最近更新 更多