-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbucket.py
More file actions
43 lines (32 loc) · 884 Bytes
/
Copy pathbucket.py
File metadata and controls
43 lines (32 loc) · 884 Bytes
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
import boto3
import os
from dotenv import load_dotenv
import datetime
load_dotenv()
ACCESS_KEY = os.getenv('ACCESS_KEY')
SECRET_KEY = os.getenv('SECRET_KEY')
CLUSTER_URL = os.getenv('CLUSTER_URL')
BUCKET_LABEL = os.getenv('BUCKET_LABEL')
linode_obj_config = {
"aws_access_key_id": ACCESS_KEY,
"aws_secret_access_key": SECRET_KEY,
"endpoint_url":CLUSTER_URL,
}
client = boto3.client("s3", **linode_obj_config)
ct = datetime.datetime.now()
# ts store timestamp of current time
ts = ct.timestamp()
stamp = round(ts)
filename = "daily_" + str(stamp) + ".txt"
print(filename)
f = open("data/" + filename, "x")
f.write('{"temp":80}')
f.close()
# print(client.list_objects(
# Bucket=BUCKET_LABEL,)["Contents"])
# client.put_object()
client.upload_file(
Filename='data/' +filename,
Bucket=BUCKET_LABEL,
Key=filename,
ExtraArgs={'ACL':'public-read'})