'How to copy folder having files, also having sub-folders with different files to aws S3 bukcet with same folder level structure using python language

Hi all can you please help to figure out this issue

How to copy a folder having py files, and aslo having sub folder level files which are present in a particular path with the same folder structure to asw s3 bucket path. The files should be reflected as same in the way how they are look like folder level that should be same in s3 bucket path as well



Solution 1:[1]

There is a fully fledged Python library for this. Install it via

pip install s3

The documentation is well written and you should have no trouble following it. The examples section shows how to upload file to S3

storage.write("example", remote_name, headers=headers)

You should be able to instruct the package to upload the folders and subfolders while maintaining their folder structure. You can also use os.walk to walk through your files and directories if you need to individually pick which files and folders need to be uploaded.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 M B