如何在不下載的情況下在霧中獲取s3對象的大小?霧 - 在S3中獲取對象的大小
例如:
connection.get_object(dir.key, latest_backup.key).body.size
要求我先下載的對象。
如何在下載前瞭解尺寸?
如何在不下載的情況下在霧中獲取s3對象的大小?霧 - 在S3中獲取對象的大小
例如:
connection.get_object(dir.key, latest_backup.key).body.size
要求我先下載的對象。
如何在下載前瞭解尺寸?
要查找的文件的大小,這樣做:
connection.head_object(bucket_name, object_name, options = {})
而且在回來的對象查找此:
Content-Length
這也會給你喜歡的校驗和其他的好信息在ETag和其他類似的東西。
參考:http://rubydoc.info/gems/fog/Fog/Storage/AWS/Real#head_object-instance_method
remote_file.content_length
確實爲我的伎倆(霧1.21.0)
其中remote_file
從遠程目錄中得到,像這樣:
def connection
Fog::Storage.new(fog_config)
end
def directory
connection.directories.get(bucket)
end
def remote_file
remote_files = directory.files.last
end
你嘗試訪問對象的元數據通過'metadata'方法? – pjam 2013-04-04 22:01:00
我不知道有一個。我無法在文檔中看到它...可以提供示例或文檔鏈接嗎?乾杯。 – 2013-04-04 22:40:39
對不起,我以爲我給你的鏈接,在這裏我找到了一個:http://docs.aws.amazon.com/AWSRubySDK/latest/frames.html,這個網站很爛,所以我不能給你確切的鏈接,但在s3中,有一個'S3Object'方法列表,它說明了一個元數據方法 – pjam 2013-04-04 22:46:14