AWSContent Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | AWSContentManager.h AWSContentManager.m |
Overview
The content object that holds the cached data and its metadata.
A category to add remote file removal to AWSContent.
Other Methods
key
The Amazon S3 key associated with the content.
@property (nonatomic, readonly) NSString *keyDeclared In
AWSContentManager.h
directory
Shows if the content is a directory.
@property (nonatomic, readonly, getter=isDirectory) BOOL directoryDeclared In
AWSContentManager.h
status
The status of the content.
@property (nonatomic, readonly) AWSContentStatusType statusDeclared In
AWSContentManager.h
progress
The transfer progress.
@property (nonatomic, readonly) NSProgress *progressDeclared In
AWSContentManager.h
knownRemoteByteCount
The last known size reported by the Amazon S3. May be different from the actual size if the file was modified on the server.
@property (nonatomic, readonly) NSUInteger knownRemoteByteCountDeclared In
AWSContentManager.h
knownRemoteLastModifiedDate
The last known last modified date reported by the Amazon S3. May be different from the actual last modified date if the file was modified on the server.
@property (nonatomic, readonly) NSDate *knownRemoteLastModifiedDateDeclared In
AWSContentManager.h
cachedData
The cached data object.
@property (nonatomic, readonly) NSData *cachedDataDeclared In
AWSContentManager.h
fileSize
The cached data size.
@property (nonatomic, readonly) NSUInteger fileSizeDeclared In
AWSContentManager.h
downloadedDate
The date the cached data was downloaded.
@property (nonatomic, readonly) NSDate *downloadedDateDeclared In
AWSContentManager.h
cached
Wheather the content is locally cached.
@property (nonatomic, readonly, getter=isCached) BOOL cachedDeclared In
AWSContentManager.h
pinned
Weather the content is pinned. Pinned objects are not subject to the content cache limit.
@property (nonatomic, readonly, getter=isPinned) BOOL pinnedDeclared In
AWSContentManager.h
– downloadWithDownloadType:pinOnCompletion:progressBlock:completionHandler:
Downloads a file from the remote server.
- (void)downloadWithDownloadType:(AWSContentDownloadType)loadingType pinOnCompletion:(BOOL)pinOnCompletion progressBlock:(void ( ^ _Nullable ) ( AWSContent *content , NSProgress *progress ))progressBlock completionHandler:(void ( ^ ) ( AWSContent *_Nullable content , NSData *_Nullable data , NSError *_Nullable error ))completionHandlerParameters
loadingType |
Specifies the loading behavior for downloading data. |
|---|---|
pinOnCompletion |
When set to |
progressBlock |
The progress feedback block. |
completionHandler |
The completion handler block. |
Discussion
Swift
func downloadContent(content: AWSContent, pinOnCompletion: Bool) {
content.downloadWithDownloadType( .IfNewerExists, pinOnCompletion: pinOnCompletion, progressBlock: {(content: AWSContent?, progress: NSProgress?) -> Void in
// Handle progress feedback
}, completionHandler: {(content: AWSContent?, data: NSData?, error: NSError?) -> Void in
if let error = error {
print("Failed to download a content from a server.)")
// Handle error here
return
}
// Handle successful download here
})
}
Objective-C
- (void)downloadContent:(AWSContent *)content
pinOnCompletion:(BOOL)pinOnCompletion {
[content downloadWithDownloadType:AWSContentDownloadTypeIfNewerExists
pinOnCompletion:pinOnCompletion
progressBlock:^(AWSContent *content, NSProgress *progress) {
// Handle progress feedback
}
completionHandler:^(AWSContent *content, NSData *data, NSError *error) {
if (error) {
NSLog(@"Failed to download a content from a server. %@", error);
// Handle error here
return;
}
// Handle successful download here
}];
}
Declared In
AWSContentManager.h
– getRemoteFileURLWithCompletionHandler:
Gets Presigned URL or the Cloud Front URL for the file.
- (void)getRemoteFileURLWithCompletionHandler:(void ( ^ ) ( NSURL *_Nullable url , NSError *_Nullable error ))completionHandlerParameters
completionHandler |
The completion handler block. |
|---|
Discussion
Swift
func getContentURL(content: AWSContent) {
content.getRemoteFileURLWithCompletionHandler({ (url: NSURL?, error: NSError?) -> Void in
guard let url = url else {
NSLog("Error getting URL for file. \(error)")
return
}
// Handle successfully generated URL here
})
}
Objective-C
- (void)getContentURL:(AWSContent *)content {
[content getRemoteFileURLWithCompletionHandler:^(NSURL *url, NSError *error) {
if (error) {
NSLog(@"Failed to get a valid URL from a server. %@", error);
}
// handle successfully generated URL here
}];
}
Declared In
AWSContentManager.h
– pin
Pins the locally cached object. Pinned objects are not subject to the content cache limit.
- (void)pinDeclared In
AWSContentManager.h
– unPin
Unpins the pinned object. It may purge the content cache if the content cache does not have enough available space to fit the unpinned data.
- (void)unPinDeclared In
AWSContentManager.h
– removeLocal
Removes locally cached data regardless of the pinning status.
- (void)removeLocalDeclared In
AWSContentManager.h
Other Methods
– removeRemoteContentWithCompletionHandler:
Removes the remote file associated with AWSContent.
- (void)removeRemoteContentWithCompletionHandler:(void ( ^ ) ( AWSContent *content , NSError *error ))completionHandlerParameters
completionHandler |
The completion handler block. |
|---|
Discussion
Swift
func removeContent(content: AWSContent) {
content.removeRemoteContentWithCompletionHandler({(content: AWSContent?, error: NSError?) -> Void in
if let error = error {
print("Failed to delete an object from the remote server. \(error)")
} else {
print("Success")
// Do something further
}
})
}
Objective-C
- (void)removeContent:(AWSContent *)content {
[content removeRemoteContentWithCompletionHandler:^(AWSContent *content, NSError *error) {
if (error) {
NSLog(@"Failed to delete an object from the remote server. %@", error);
} else {
NSLog(@"Success");
// Do something further
}
}];
}
Declared In
AWSUserFileManager.h