从 Url 将文件上传到 Amazon S3 [文件不存在错误]
目前我正在使用 viddler 进行不同的服务和视频上传。我还想在亚马逊 s3 服务器上提供内容备份服务。为了开发此服务,我使用了适用于 .NET 的 AWS 开发工具包。当我尝试上传将 URL 作为文件路径传递的文件时,出现以下错误:“指定的文件不存在”
我的问题是:AWS SDK 是否支持以编程方式或任何其他方法将内容从另一个域上传到 s3?
我的代码:
PutObjectRequest titledRequest = new PutObjectRequest();
titledRequest.WithMetaData("title", "the title")
//.WithContentBody("this object has a title")
.WithBucketName(bucketName)
.WithFilePath("http://download.microsoft.com/download/9/2/2/9222D67F-7630-4F49-BD26- 476B51517FC1/FileFormatConverters.exe") //does url support?
.WithTimeout(3600000)
.WithReadWriteTimeout(3600000)
.WithKey("test.ext");
using (S3Response responseWithMetadata = client.PutObject(titledRequest))
{
}
Currently I am using viddler for different service and videos uploading. I also would like to make a service for content backup on an amazon s3 server. For developing this service I used the AWS SDK for .NET. When I try to upload a file passing the URL as the file path it gives me the following error:"the specified file does not exist"
My question is: Does the AWS SDK support content uploading from another domain to s3 programmatically or any other method?
My code:
PutObjectRequest titledRequest = new PutObjectRequest();
titledRequest.WithMetaData("title", "the title")
//.WithContentBody("this object has a title")
.WithBucketName(bucketName)
.WithFilePath("http://download.microsoft.com/download/9/2/2/9222D67F-7630-4F49-BD26- 476B51517FC1/FileFormatConverters.exe") //does url support?
.WithTimeout(3600000)
.WithReadWriteTimeout(3600000)
.WithKey("test.ext");
using (S3Response responseWithMetadata = client.PutObject(titledRequest))
{
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上传到 S3 需要带有内容长度元数据集的整个字节流。您必须创建一个实时缓冲区,用于从源 url 接收数据并将其异步传送到 S3 PutObject 请求。
实现此目的的方法之一是使用两个缓冲区将来自源的字节流简化为可用作分段上传一部分的设定块大小。
我怀疑 SDK 是否支持此功能,因此您必须使用对 AWS 服务的 REST 调用来实现此功能。
Uploads to S3 require the entire bytestream with the content-length metadata set. You would have to create a live buffer that receives data from the source url and pipe it to the S3 PutObject request asynchronously.
One of the ways you can do this is have two buffers to streamline the bytestream from the source into set chunk sizes that can be used as a part of the multipart upload.
The SDK, I doubt has support for this so you would have to implement this using REST calls to the AWS service.