- Newest
- Most votes
- Most comments
S3 differs from a normal filesystem as it has a flat structure instead of hierarchical as we are used to, so there's no real folders in S3, it's simulated with prefixes.
That said there is no supported operation on s3 to upload a folder directly, instead you must especify all files to be uploaded. You might think you can, through console experience, but that's a convenience, behind the curtains the UI uploads each file individually.
On Cloud9 you could use a code script to upload all files from the desired folder into an s3 "folder", one by one or in parallel with threading. I will leave here a code snippet using boto3 on python to upload one by one:
import os import boto3 S3_BUCKET= 'my_bucket' S3_PREFIX = 'path/to/my/files/' LOCAL_FOLDER_PATH = '/path/to/files/' session = boto3.Session() # Authentication happens through EC2 role s3 = session.client('s3') for file in os.listdir(LOCAL_FOLDER_PATH): s3_file = S3_PREFIX + file s3.upload_file(file, S3_BUCKET, s3_file)
Note that there are a another ways to upload using boto3, another is to create a higher-level API object using **session.resource('s3) **and use it's methods but resources are not updated anymore so may lack a few features.
Also important to say that there are indeed some solutions that will let you upload a folder to s3 in single call, but they all have to upload one by one under the hood.
Hope this answers your question, if you still have any question please let me know.
For multiple folders and files, you can use AWS CLI's s3 sync command. To sync from local folder in Cloud 9 to S3 bucket
aws s3 sync . s3://<MYBUCKET>/<FOLDER>
If you have not, you will need to configure your credentials, i.e.
aws configure
If this is a few files, consider using AWS Toolkit. See Upload a file to an S3 bucket using the interface
Relevant content
- asked 19 days ago
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 8 months ago