FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/examples/upload_with_zone.py at patch-1 · dawncold/python-sdk · GitHub
dawncold
/
python-sdk
Public
forked from
qiniu/python-sdk
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-sdk
/
examples
/
upload_with_zone.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (29 loc) · 877 Bytes
Breadcrumbs
python-sdk
/
examples
/
upload_with_zone.py
Copy path
File metadata and controls
38 lines (29 loc) · 877 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# -*- coding: utf-8 -*-
# flake8: noqa
from
qiniu
import
Auth
,
put_file
,
etag
,
urlsafe_base64_encode
import
qiniu
.
config
from
qiniu
import
Zone
,
set_default
# 需要填写你的 Access Key 和 Secret Key
access_key
=
'...'
secret_key
=
'...'
# 构建鉴权对象
q
=
Auth
(
access_key
,
secret_key
)
# 要上传的空间
bucket_name
=
'Bucket_Name'
# 上传到七牛后保存的文件名
key
=
'my-python-logo.png'
# 生成上传 Token,可以指定过期时间等
token
=
q
.
upload_token
(
bucket_name
,
key
,
3600
)
# 要上传文件的本地路径
localfile
=
'stat.py'
# 指定固定的zone
zone
=
Zone
(
up_host
=
'uptest.qiniu.com'
,
up_host_backup
=
'uptest.qiniu.com'
,
io_host
=
'iovip.qbox.me'
,
scheme
=
'http'
)
set_default
(
default_zone
=
zone
)
ret
,
info
=
put_file
(
token
,
key
,
localfile
)
print
(
info
)
assert
ret
[
'key'
]
==
key
assert
ret
[
'hash'
]
==
etag
(
localfile
)
Back
|
FazBrowse Home
|
New Git URL