我有一個包含文件的S3存儲桶。我可以成功下載並在我的應用程序上顯示該文件。如何獲取文件的上傳日期Amazon S3,AWS IOS SDK
但是我想知道,如果文檔是最新的或沒有。使用Firefox S3擴展,我可以看到在存儲桶文件名中,文件大小和上傳時間保存到S3。上傳時間的一個例子是10/10/2012 11:35 PM
獲取URL我用
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
// Set the content type so that the browser will treat the URL as an image.
S3ResponseHeaderOverrides *override = [[S3ResponseHeaderOverrides alloc] init];
override.contentType = @" ";
// Request a pre-signed URL to picture that has been uplaoded.
S3GetPreSignedURLRequest *gpsur = [[S3GetPreSignedURLRequest alloc] init];
gpsur.key = _fileName;
gpsur.bucket = [Constants pictureBucket];
gpsur.expires = [NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval) 3600]; // Added an hour's worth of seconds to the current time.
gpsur.responseHeaderOverrides = override;
// Get the URL
NSError *error;
NSURL *url = [self.s3 getPreSignedURL:gpsur error:&error];
我怎樣才能在Amazon S3文件的上傳日期?
編輯答案::::
OK由於與下面的方法回答,我可以得到的日期
S3GetObjectMetadataRequest *getMetadataRequest = [[S3GetObjectMetadataRequest alloc] initWithKey:_fileName withBucket:[Constants pictureBucket]];
S3GetObjectMetadataResponse *getMetadataResponse = [self.s3 getObjectMetadata:getMetadataRequest];
NSString *fileLastModifiedDate = [[NSString alloc] init];
fileLastModifiedDate = [NSString stringWithFormat:@"%@",getMetadataResponse.lastModified];
NSLog(@"Last Modified date %@",fileLastModifiedDate);