-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupload.py
More file actions
33 lines (24 loc) · 924 Bytes
/
upload.py
File metadata and controls
33 lines (24 loc) · 924 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
import os
import sys
import oss2
bucket = oss2.Bucket(
oss2.Auth(
os.environ.get("OSS_ACCESS_KEY_ID"),
os.environ.get("OSS_ACCESS_KEY_SECRET"),
),
os.environ.get("OSS_ENDPOINT", "http://oss-accelerate.aliyuncs.com"),
'drycc'
)
def upload(filename, filepath):
with open(filepath, "rb") as f:
result = bucket.put_object(filename, f.read())
print("upload %s %s" % (filename, result.status))
def upload_list(stack_name, dist_dir):
for root, _, files in os.walk(os.path.join(dist_dir, stack_name)):
for _filename in files:
if _filename.startswith(stack_name) and _filename.endswith(".tar.gz"):
filename = os.path.join("stacks", stack_name, _filename)
filepath = os.path.join(root, _filename)
upload(filename, filepath)
if __name__ == "__main__":
upload_list(sys.argv[1], sys.argv[2])