Skip to content

Commit bf767ab

Browse files
Replace access tokens
1 parent e61d744 commit bf767ab

File tree

6 files changed

+65
-43
lines changed

6 files changed

+65
-43
lines changed

generatepdf/Madhutest.pdf

-24.3 KB
Binary file not shown.
Binary file not shown.

generatepdf/pdf/s3file.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def upload_file(image_path):
3030

3131

3232

33-
import boto3
34-
b_name = "ivin-pro-data-conversion"
35-
s3 = boto3.client("s3")
36-
b_res = s3.list_buckets()
37-
# for i in b_res['Buckets']:
38-
# print(i)
39-
with open(r"C:\Users\anves\Pictures\as.png",'rb') as img:
40-
s3.upload_fileobj(img,b_name,"testfile.jpg")
33+
# import boto3
34+
# b_name = "ivin-pro-data-conversion"
35+
# s3 = boto3.client("s3")
36+
# b_res = s3.list_buckets()
37+
# # for i in b_res['Buckets']:
38+
# # print(i)
39+
# with open(r"C:\Users\anves\Pictures\as.png",'rb') as img:
40+
# s3.upload_fileobj(img,b_name,"testfile.jpg")
4141
#
4242
# s3.download_file(b_name,"testfile.jpg ","download.jpg")
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div><h1>madhu</h1></div>
2+
3+
<html>
4+
<head>
5+
<title>Href Attribute Example</title>
6+
</head>
7+
<body>
8+
<h1>Href Attribute Example</h1>
9+
<p>
10+
<a href="https://www.freecodecamp.org/contribute/">The freeCodeCamp Contribution Page</a> shows you how and where you can contribute to freeCodeCamp's community and growth.
11+
</p>
12+
</body>
13+
</html>
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div><h1>madhu</h1></div>
2+
3+
<html>
4+
<head>
5+
<title>Href Attribute Example</title>
6+
</head>
7+
<body>
8+
<h1>Href Attribute Example</h1>
9+
<p>
10+
<a href="https://www.freecodecamp.org/contribute/">The freeCodeCamp Contribution Page</a> shows you how and where you can contribute to freeCodeCamp's community and growth.
11+
</p>
12+
</body>
13+
</html>

main.py

+31-35
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,44 @@
1-
# import boto3
2-
# from botocore.exceptions import NoCredentialsError
1+
import boto3
2+
from botocore.exceptions import NoCredentialsError
33

4-
# # ACCESS_KEY = 'AKIAVUQMV7NGTJBURAUJ'
5-
# # SECRET_KEY = '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'
6-
# # locations = "Asia Pacific ap-south-1"
7-
# ACCESS_KEY = 'AKIAVUQMV7NGS6WA2KEM'
8-
# SECRET_KEY = '/n7JXM+BDiKnkuvWOMcc5VY2hS+rF2Lm/DEGfs8I'
4+
# locations = "Asia Pacific ap-south-1"
5+
ACCESS_KEY = '*****' #replace * with your s3 bucket access key#
6+
SECRET_KEY = '*****' #replace * with your s3 bucket secret key#
97

10-
# import logging
11-
# import boto3
12-
# from botocore.exceptions import ClientError
13-
# import os
8+
import logging
9+
import boto3
10+
from botocore.exceptions import ClientError
11+
import os
1412

1513

16-
# import logging
17-
# import boto3
18-
# from botocore.exceptions import ClientError
19-
# import os
14+
import logging
15+
import boto3
16+
from botocore.exceptions import ClientError
17+
import os
2018

2119

2220

23-
# import boto3
24-
# import os
21+
import boto3
22+
import os
2523

2624

27-
# def upload_files(path):
28-
# session = boto3.Session(
29-
# aws_access_key_id=ACCESS_KEY,
30-
# aws_secret_access_key=SECRET_KEY,
31-
# region_name='ap-southeast-1'
32-
# )
33-
# s3 = session.resource('s3')
34-
# bucket = s3.Bucket('')
25+
def upload_files(path):
26+
session = boto3.Session(
27+
aws_access_key_id=ACCESS_KEY,
28+
aws_secret_access_key=SECRET_KEY,
29+
region_name='ap-southeast-1'
30+
)
31+
s3 = session.resource('s3')
32+
bucket = s3.Bucket('')
3533

36-
# for subdir, dirs, files in os.walk(path):
37-
# for file in files:
38-
# full_path = os.path.join(subdir, file)
39-
# with open(full_path, 'rb') as data:
40-
# bucket.put_object(Key=full_path[len(path) + 1:], Body=data)
34+
for subdir, dirs, files in os.walk(path):
35+
for file in files:
36+
full_path = os.path.join(subdir, file)
37+
with open(full_path, 'rb') as data:
38+
bucket.put_object(Key=full_path[len(path) + 1:], Body=data)
4139

4240

43-
# if __name__ == "__main__":
44-
# d = upload_files(r'D:\projects\New folder (2)\PDF-Generator-Python\generatepdf\Madhutest.pdf')
45-
# print(d)
41+
if __name__ == "__main__":
42+
d = upload_files(r'D:\projects\New folder (2)\PDF-Generator-Python\generatepdf\Madhutest.pdf')
43+
print(d)
4644

47-
48-
# arn:aws:s3:::ivin-pro-data-conversion

0 commit comments

Comments
 (0)