[英]Appending bytes using Amazon S3 .Net SDK
I have the following piece of code which works great for a simple file upload. 我有以下代码,适用于简单的文件上传。 But let's say I wanted to append to an existing file or simply upload random chunks of bytes, like the first and last 10 bytes?
但是,假设我想要附加到现有文件或只是上传随机字节块,比如第一个和最后10个字节? Is this even possible with the official SDK?
官方SDK甚至可以实现这一点吗?
PutObjectRequest request = new PutObjectRequest();
FileStream fs = new FileStream(@"C:\myFolder\MyFile.bin", FileMode.Open);
request.WithInputStream(fs);
request.WithBucketName(bucketName);
request.WithKey(keyName);
client.PutObject(request);
fs.Close();
This previous answer appears to no longer be the case. 之前的答案似乎不再是这种情况。 You can currently manage an append like process by using an existing object as the initial part of a multi-part upload.
您现在可以使用现有对象作为多部分上载的初始部分来管理类似进程的追加。 Then delete the previous object when done transferring.
完成传输后删除上一个对象。
See: 看到:
http://docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjctsUsingLLNetMPUapi.html http://docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjctsUsingLLNetMPUapi.html
http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPartCopy.html http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPartCopy.html
There is no way to append data to existing objects in S3. 无法在S3中将数据附加到现有对象。 You have to overwrite the entire file.
您必须覆盖整个文件。
Although, in saying that, it is possible to a degree with Amazon's large file support. 虽然,在说,有可能在某种程度上亚马逊的大文件支持。 With this uploads are broken into chunks and reassembled on S3.
随着这个上传被分成几个块并在S3上重新组装。 But you have to do it as part of a single transfer and its only for large files.
但是,您必须将其作为单个传输的一部分进行,并且仅针对大型文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.