Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/object_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import oss2

import datetime


# 以下代码展示了基本的文件上传、下载、罗列、删除用法。

Expand Down Expand Up @@ -35,10 +37,10 @@
bucket.put_object('motto.txt', 'Never give up. - Jack Ma')

# 获取Object的metadata
object_meta = bucket.get_object_meta('你的对象名')
print('last modified: ' + object_meta.last_modified)
object_meta = bucket.get_object_meta('motto.txt')
print('last modified: ' +datetime.datetime.fromtimestamp(object_meta.last_modified).strftime('%Y-%m-%d %H:%M:%S'))
print('etag: ' + object_meta.etag)
print('size: ' + object_meta.content_length)
print('size: ' + str(object_meta.content_length))

# 下载到本地文件
bucket.get_object_to_file('motto.txt', '本地文件名.txt')
Expand Down