2012-10-11 2 views
4

파일이있는 S3 버킷이 있습니다. 내 앱에서 성공적으로 파일을 다운로드하고 표시 할 수 있습니다.파일의 업로드 날짜를 얻는 방법 Amazon S3, AWS IOS SDK

그러나 문서가 최신인지 아닌지를 알고 싶습니다. Firefox S3 확장을 사용하면 버켓 파일 이름에서 파일 크기와 업로드 시간이 S3에 저장된다는 것을 알 수 있습니다. 업로드 시간의 예는 10/10/2012 11:35 PM

내가

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]; 

가 어떻게 아마존 S3에있는 파일의 업로드 날짜를 얻을 수 있습니다 사용하는 URL을 얻을 수 있습니다?

편집 :::: 답변

OK 덕분에 내가 날짜 당신은 S3GetObjectMetadataRequest을해야

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); 

답변

2

모드 퍼스 탕, 한 가지 답변에 대한 코드를하지만. 응답에서 액세스하기 전에 NSString 객체를 할당 할 필요가 없습니다.

NSString *fileModifiedDate = getMetadataResponse.lastModified; 
NSLog(@"Last Modified date %@", fileModifiedDate);