How to Download File Upload Date Amazon S3 AWS IOS SDK

I have an S3 bucket with files in it. I can successfully download and display the file in my application.

However, I want to find out if the document is the last or not. With the Firefox S3 extension, I see that in the bucket file name, the file size and download time are saved on S3. An example of loading time is 10/10/2012 11:35 PM

to get url i use

 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 worth of seconds to the current time. gpsur.responseHeaderOverrides = override; // Get the URL NSError *error; NSURL *url = [self.s3 getPreSignedURL:gpsur error:&error]; 

How can I upload a file upload date to Amazon S3?

EDIT :: ANSWER

OK, responding with the following method, I can get the date

 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); 
+4
source share
2 answers

You need to do S3GetObjectMetadataRequest.

 S3GetObjectMetadataRequest *getMetadataRequest = [[S3GetObjectMetadataRequest alloc] initWithKey:filePath withBucket:BUCKET_NAME]; S3GetObjectMetadataResponse *getMetadataResponse = [self getObjectMetadata:getMetadataRequest]; 

http://docs.amazonwebservices.com/AmazonS3/latest/dev/UsingMetadata.html

+7
source

Mord Fustang, something though about the code in your answer. You do not need to allocate an NSString object before accessing it from a response.

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

Source: https://habr.com/ru/post/1439179/


All Articles