2017-06-12 77 views

回答

2
bucket_name = 'bucket-one' 
file_name = 'my_file' 

object = s3.Object(bucket_name, file_name) 
print object.last_modified 

或者乾脆:

print s3.Object(bucket_name, file_name).last_modified 
2

希望這有助於你....

這將讓特定對象的最後修改時間在S3存儲桶

import boto3 
import time 
from pprint import pprint 

s3 = boto3.resource('s3',region_name='S3_BUCKET_REGION_NAME') 
bucket='BUCKET_NAME' 
key='OBJECT_NAME' 
summaryDetails=s3.ObjectSummary(bucket,key) 
timeFormat=summaryDetails.last_modified 
formatedTime=timeFormat.strftime("%Y-%m-%d %H:%M:%S") 
pprint('Bucket name is '+ bucket + ' and key name is ' + key + ' and last modified at time '+ formatedTime) 

謝謝....