这是Java中想知道它们是否具有快速等效项的相同代码,
允许您将文件分解成几个部分:

long partSize = 5 * 1024 * 1024;

        try {
            AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                                    .withRegion(clientRegion)
                                    .withCredentials(new ProfileCredentialsProvider())
                                    .build();

            List<PartETag> partETags = new ArrayList<PartETag>();


            InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(bucketName, keyName);
            InitiateMultipartUploadResult initResponse = s3Client.initiateMultipartUpload(initRequest);

            long filePosition = 0;
            for (int i = 1; filePosition < contentLength; i++) {
                partSize = Math.min(partSize, (contentLength - filePosition));


                UploadPartRequest uploadRequest = new UploadPartRequest()
                        .withBucketName(bucketName)
                        .withKey(keyName)
                        .withUploadId(initResponse.getUploadId())
                        .withPartNumber(i)
                        .withFileOffset(filePosition)
                        .withFile(file)
                        .withPartSize(partSize);

                UploadPartResult uploadResult = s3Client.uploadPart(uploadRequest);
                partETags.add(uploadResult.getPartETag());

                filePosition += partSize;
            }


            CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(bucketName, keyName,
                    initResponse.getUploadId(), partETags);
            s3Client.completeMultipartUpload(compRequest);
        }

最佳答案

您可以在此处使用来自AWSiOSSDKv2的AWSS3客户端:https://github.com/aws/aws-sdk-ios

您要查找的请求是:https://github.com/aws/aws-sdk-ios/blob/master/AWSS3/AWSS3Model.h#L6618,可以通过以下API调用该请求:https://github.com/aws/aws-sdk-ios/blob/master/AWSS3/AWSS3Service.h#L1994

谢谢,
罗汉

关于java - 是否有低级Swift类可以在AWS S3中上传文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52315564/

10-10 17:46