-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
47 lines (34 loc) · 1.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<<<<<<< HEAD
=======
import boto3
from botocore.exceptions import NoCredentialsError
# locations = "Asia Pacific ap-south-1"
ACCESS_KEY = '*****' #replace * with your s3 bucket access key#
SECRET_KEY = '*****' #replace * with your s3 bucket secret key#
import logging
import boto3
from botocore.exceptions import ClientError
import os
import logging
import boto3
from botocore.exceptions import ClientError
import os
import boto3
import os
def upload_files(path):
session = boto3.Session(
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
region_name='ap-southeast-1'
)
s3 = session.resource('s3')
bucket = s3.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__":
d = upload_files(r'D:\projects\New folder (2)\PDF-Generator-Python\generatepdf\Madhutest.pdf')
print(d)
>>>>>>> 867119521e7d3cd9aececa11d692954e5ae2eeda