Omkar008 commited on
Commit
87cc66e
1 Parent(s): 238f6ea

Update test.py

Browse files
Files changed (1) hide show
  1. test.py +16 -5
test.py CHANGED
@@ -70,6 +70,8 @@ async def auth_google(request: Request):
70
  print(gmail_response.json())
71
  # Fetch attachments from the first message
72
  attachments = []
 
 
73
  for i,message in enumerate(messages) :
74
  print(i)
75
  print(message)
@@ -94,15 +96,24 @@ async def auth_google(request: Request):
94
  filename = part.get("filename", "untitled.txt")
95
 
96
  if data:
 
97
  # Decode base64-encoded attachment data
98
  attachment_content = base64.urlsafe_b64decode(data.encode("UTF-8"))
 
 
 
 
99
 
100
- # Save the attachment to a file
101
- save_path = f"/Users/omkarmalpure/Documents/Gmail_API/attachments/{filename}"
102
- with open(save_path, "wb") as file:
103
- file.write(attachment_content)
 
 
 
 
104
 
105
- attachments.append(save_path)
106
 
107
  print(attachments)
108
  print(len(attachments))
 
70
  print(gmail_response.json())
71
  # Fetch attachments from the first message
72
  attachments = []
73
+ attachment_no = 0
74
+ data_new = [[]]
75
  for i,message in enumerate(messages) :
76
  print(i)
77
  print(message)
 
96
  filename = part.get("filename", "untitled.txt")
97
 
98
  if data:
99
+ data_new.append([data.encode("utf-8")])
100
  # Decode base64-encoded attachment data
101
  attachment_content = base64.urlsafe_b64decode(data.encode("UTF-8"))
102
+ # print(attachment_content)
103
+ print("yo")
104
+ print(data_new)
105
+ attachment_no+=1
106
 
107
+ # if data:
108
+ # # Decode base64-encoded attachment data
109
+ # attachment_content = base64.urlsafe_b64decode(data.encode("UTF-8"))
110
+
111
+ # # Save the attachment to a file
112
+ # save_path = f"/Users/omkarmalpure/Documents/Gmail_API/attachments/{filename}"
113
+ # with open(save_path, "wb") as file:
114
+ # file.write(attachment_content)
115
 
116
+ # attachments.append(save_path)
117
 
118
  print(attachments)
119
  print(len(attachments))