I am writing an application and we need to transfer files between different s3 accounts, we do not want to save the file locally before uploading to the target s3 account.
So we get the source file stream using this:
public Stream GetFileStream(string path) { var pathPieces = path.Split('/'); string bucket = pathPieces[0]; string fileName = pathPieces[pathPieces.Length - 1]; GetObjectRequest request = new GetObjectRequest(); request.BucketName = bucket; request.Key = fileName; GetObjectResponse response = Client.GetObject(request); return response.ResponseStream; }
And after that we use this stream to load to the destination:
TransferUtility transferUtility = new TransferUtility(Client); transferUtility.S3Client.PutBucket(new PutBucketRequest() { UseClientRegion = true }.WithBucketName(bucket)); TransferUtilityUploadRequest request = new TransferUtilityUploadRequest() .WithBucketName(bucket) .WithKey(key) .WithPartSize(1024) .WithTimeout(100 * 60 * 60 * 1000) .WithAutoCloseStream(true) .WithCannedACL(S3CannedACL.PublicReadWrite) .WithInputStream(fileStream) as TransferUtilityUploadRequest; transferUtility.Upload(request);
But in the last line of the call to the "Download" function, I always get this error: This thread does not support search operations.
Is there any other way to do what I'm trying to do? because it is not the right way.
source share