-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy paths3file.py
62 lines (48 loc) · 1.78 KB
/
s3file.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import requests
token = "#######################################################################################"
import boto3
def uploadfile(image_path):
url = 'https://staging-api.vivifyhealthcare.com/ImageUpload/DocUpload/'
# url = "http://127.0.0.1:8008/pdf/gen/"
headers = Imageheaders = {
'Accept-Language': 'en-US',
'Authorization': f'Bearer {token}'
}
import PyPDF2
print(image_path)
pdfFileObj = open(image_path, 'rb')
# pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
files = {'UploadDoc': pdfFileObj}
response = requests.post(url,files=files,headers=headers)
print(response.status_code)
imageurl = response.json()['Result']
doc = (imageurl.items())
for i in doc:
url = (i[1])
return url
# image_path = r"D:\projects\New folder (2)\PDF-Generator-Python\generatepdf\Lifeeazy-HealthSummaryl.pdf"
# # image_path = r"D:\projects\New folder (2)\test.txt"
# upload_file(image_path=image_path)
# import boto3
# b_name = "ivin-pro-data-conversion"
# s3 = boto3.client("s3")
# b_res = s3.list_buckets()
# # for i in b_res['Buckets']:
# # print(i)
# with open(r"C:\Users\anves\Pictures\as.png",'rb') as img:
# s3.upload_fileobj(img,b_name,"testfile.jpg")
#
# s3.download_file(b_name,"testfile.jpg ","download.jpg")
# def uploadfile(file):
# s3 = boto3.client("s3")
# with open(file,'rb') as f:
# x=s3.upload_fileobj(f,"ivin-pro-data-conversion",file)
# print(x)
# return x
# def downloadfile(file):
# s3 = boto3.resource('s3')
# s3.Bucket('ivin-pro-data-conversion').download_file(file, file)
# return "Success"
# import boto3
# s3 = boto3.resource('s3')
# s3.Bucket('ivin-pro-data-conversion').download_file('Madhutest.pdf', 'Madhutest.pdf')