Below is the function to download the files from a S3 Bucket. But the problem is I can't find how to direct those files into a network path instead of downloading into the project folder without having any control over where the files must be downloaded.
import boto3
import config
import os
import win32api
def download_all_objects_in_folder():
#= boto3.resource('s3')
s3_resource = boto3.resource('s3', aws_access_key_id=config.AWS_BUCKET_KEY, aws_secret_access_key=config.AWS_BUCKET_SECRET_KEY)
my_bucket = s3_resource.Bucket(config.BUCKET)
# Create the folder logic here
objects = my_bucket.objects.filter(Prefix='Export_20181104/')
for obj in objects:
path, filename = os.path.split(obj.key)
my_bucket.download_file(obj.key, filename,"C:\Other")
#win32api.MessageBox(0, obj.key, 'title')
print("imports completed")
Update: This is the error I am getting when I pass the custom path.
ValueError: Invalid extra_args key 'C', must be one of: ChecksumMode,
VersionId, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5,
RequestPayer, ExpectedBucketOwner
There is no difference for Python or the Boto3 SDK where you download your specified S3 object, whether that is a local or network location.
That concern is up to the operating system.
Download to the network location, just as you would download to the local location.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.