I'm able to upload files or directories to a bucket with the AWS .NET SDK, but they always end up in the root folder.
Is there a way to upload a file to an existing directory?
So I'm using a TransferUtilityUploadDirectoryRequest to upload a directory from my local disk to S3. I would like the files to be uploaded to a folder in the bucket with the same name as the folder I've selected.
For example. if I choose the directory c:/stuff to be upload, I want the contents of c:/stuff to go in BucketName/stuff, not directly into the bucket.
I hope it's clear what I'm trying to do, if not I'll try to provide more info
There are a few key terms to understanding AWS S3, the first of which is the “Bucket”. A Bucket is a logical container of objects. In traditional NAS terms, this would be a “folder”, but because S3 deals with objects and not files, the distinction becomes important.
You can have folders within folders, but not buckets within buckets. You can upload and copy objects directly into a folder.
Multipart upload allows you to upload a single object as a set of parts. Each part is a contiguous portion of the object's data. You can upload these object parts independently and in any order. If transmission of any part fails, you can retransmit that part without affecting other parts.
In the Google Cloud console, go to the Cloud Storage Buckets page. In the list of buckets, click on the name of the bucket that you want to upload an object to. In the Objects tab for the bucket, either: Drag and drop the desired files from your desktop or file manager to the main pane in the Google Cloud console.
s3://destination --recursive . That way, it is copying the contents of the current directory.
It seems after googling around, you specify a key. It took me a while, but I believe the key is something like this example:
string key = string.Format("{0}/{1}", folder, filename);
PutObjectRequest rq = new PutObjectRequest()
{
AutoCloseStream = false,
BucketName = s3BucketName,
InputStream = stream,
Key = key
};
S3ClientInstance.PutObject(rq).Dispose();
The newest version of the AWS SDK for .NET allows you to set the KeyPrefix property on the UploadDirectoryRequest (more info here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With