Last post Aug 14, 2015 05:17 AM by heyitsme
Aug 13, 2015 10:40 AM|heyitsme|LINK
I am uploading file to Amazon cloud storage using WCF Rest service. The service receives Stream as a input and this stream is being passed to CloudUpload API. Below is my code.
public void UploadFileWithStream(Stream FileStream)
TransferUtility fileTransferUtility = new
TransferUtility(new AmazonS3Client("access key", "secret access key", Amazon.RegionEndpoint.USEast1));
TransferUtilityUploadRequest fileTransferUtilityRequest = new TransferUtilityUploadRequest
BucketName = "bucketNM",
InputStream = FileStream,
StorageClass = S3StorageClass.Standard,
PartSize = 6291456,
Key = @"Trial/filenm.jpg",
CannedACL = S3CannedACL.BucketOwnerFullControl
catch (Exception ex)
I am getting the following error in this method.
Specified method is not supported. at System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.get_Length()
at Amazon.S3.Transfer.TransferUtility.IsMultipartUpload(TransferUtilityUploadRequest request)
at Amazon.S3.Transfer.TransferUtility.GetUploadCommand(TransferUtilityUploadRequest request)
at Amazon.S3.Transfer.TransferUtility.UploadHelper(TransferUtilityUploadRequest request)
at Amazon.S3.Transfer.TransferUtility.Upload(TransferUtilityUploadRequest request)
at WCFRestService.StreamAsInput.UploadFileWithStream(Stream FileStream) in D:\Research\Research\RestService\StreamAsInput.svc.cs:line 42
Any help will be greatly appreciated
Aug 13, 2015 12:59 PM|PatriceSc|LINK
Not sure. Is FileStream.CanSeek false? For now it seems to me it might be that the code tries to get the Stream length and can't (which is the case if CanSeek is false). If confirmed, double check how the Stream is created and change that until CanSeek is
true and see what happens.
Else an Amazon S3 programming forum might be better.
Aug 13, 2015 02:14 PM|heyitsme|LINK
Yes, FileStream.CanSeek is false. In REST service its false
Aug 13, 2015 02:38 PM|PatriceSc|LINK
Ah the Stream comes from ? I didn't understood the "to". It would come *from* a REST service and you would transmit that directly to Amazon?
What if you try with a MemoryStream just to test if it works? If yes then try to get the entire input Stream before sending it to Amazon.
Aug 14, 2015 05:17 AM|heyitsme|LINK
Stream comes from ?
you would transmit that directly to Amazon?
entire input Stream before sending it to Amazo