vicuna-7b· LMSYS
Arena Human Preference 55K
write a python function to upload all the files from one local folder to one directory…
- User
write a python function to upload all the files from one local folder to one directory of an S3 bucket
- Assistant
Sure, here's a Python function that uses the
boto3library to upload all files from a local folder to a directory in an S3 bucket:import boto3 import os def upload_files_to_s3(bucket_name, local_folder, s3_folder): # Connect to S3 s3 = boto3.resource('s3') s3_bucket = s3.Bucket(bucket_name) # Get the files in the local folder files = os.listdir(local_folder) # Iterate through the files and upload them to the S3 folder for file in files: file_path = os.path.join(local_folder, file) s3.meta.client.upload_file(file_path, s3_bucket, s3_folder + "/" + file) print("All files uploaded to S3 bucket.")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.