I have a folder called myfolder
containing multiple files with filename as follows,
ID001_2017-04-15.csv, ID002_2017-04-15.csv, ID001_2017-04-16.csv, ID002_2017-04-16.csv,
ID001_2017-04-17.csv, ID002_2017-04-17.csv, ID001_2017-04-18.csv, ID002_2017-04-18.csv
The date on the filename is the date the file created. For example, file ID001_2017-04-17.csv
is created on 2017-04-17. Here's how I uploaded all the files in a folder to Amazon S3,
import boto3
def upload_files(path):
session = boto3.Session(
aws_access_key_id = 'this is my access key',
aws_secret_access_key = 'this is my secret key',
region_name = 'this is my region'
)
s3 = session.resource('s3')
bucket = s3.Bucket('this is my bucket')
for subdir, dirs, files in os.walk(path):
for file in files:
full_path = os.path.join(subdir, file)
with open(full_path, 'rb') as data:
bucket.put_object(Key = full_path[len(path) + 1:], Body = data)
if __name__ == "__main__":
upload_files('path to myfolder') ## Replace this with your folder directory
My question is can I only upload files that are created today to Amazon S3?