AVFile Class Reference

Inherits from NSObject
Conforms to NSCoding
Declared in AVFile.h

Overview

A file of binary data stored on the LeanCloud servers. This can be a image, video, or anything else that an application needs to reference in a non-relational way.

+ fileWithData:

Create file from NSData.

+ (instancetype)fileWithData:(NSData *)data

Parameters

data

Data

Return Value

Instance

Discussion

Create file from NSData.

Declared In

AVFile.h

+ fileWithData:name:

Create file with a name from NSData.

+ (instancetype)fileWithData:(NSData *)data name:(NSString *_Nullable)name

Parameters

data

Data

name

Name

Return Value

Instance

Discussion

Create file with a name from NSData.

Declared In

AVFile.h

+ fileWithLocalPath:error:

Create file from Local Path

+ (instancetype _Nullable)fileWithLocalPath:(NSString *)localPath error:(NSError *__autoreleasing *)error

Parameters

localPath

Path

Return Value

Instance

Discussion

Create file from Local Path

Declared In

AVFile.h

+ fileWithRemoteURL:

Create file from Remote URL

+ (instancetype)fileWithRemoteURL:(NSURL *)remoteURL

Parameters

remoteURL

URL

Return Value

Instance

Discussion

Create file from Remote URL

Declared In

AVFile.h

+ fileWithAVObject:

Create file from AVObject

+ (instancetype)fileWithAVObject:(AVObject *)avObject

Parameters

avObject

AVObject

Return Value

Instance

Discussion

Create file from AVObject

Declared In

AVFile.h

– name

The name of the file.

- (NSString *_Nullable)name

Discussion

The name of the file.

Declared In

AVFile.h

– objectId

The id of the file.

- (NSString *_Nullable)objectId

Discussion

The id of the file.

Declared In

AVFile.h

– url

The url of the file.

- (NSString *_Nullable)url

Discussion

The url of the file.

Declared In

AVFile.h

  metaData

File metadata, caller is able to store additional values here.

@property (nonatomic, strong, nullable) NSDictionary *metaData

Discussion

File metadata, caller is able to store additional values here.

Declared In

AVFile.h

  ownerId

Owner ID of file, Customizable.

@property (nonatomic, strong, nullable) NSString *ownerId

Discussion

Owner ID of file, Customizable.

Declared In

AVFile.h

  checksum

Checksum of file, Customizable.

@property (nonatomic, strong, nullable) NSString *checksum

Discussion

Checksum of file, Customizable.

Declared In

AVFile.h

– size

Size of file.

- (NSUInteger)size

Discussion

Size of file.

Declared In

AVFile.h

– pathExtension

Path Extension of file.

- (NSString *_Nullable)pathExtension

Discussion

Path Extension of file.

Declared In

AVFile.h

– mimeType

MIME Type of file.

- (NSString *_Nullable)mimeType

Discussion

MIME Type of file.

Declared In

AVFile.h

  ACL

The access control list for this file.

@property (nonatomic, strong, nullable) AVACL *ACL

Discussion

The access control list for this file.

Declared In

AVFile.h

  uploadingHeaders

Request headers for file uploading.

@property (nonatomic, strong, nullable) NSDictionary<NSString*NSString*> *uploadingHeaders

Discussion

Request headers for file uploading.

Some file hosting services allow you set custom headers in uploading request. Currently, it only supports files in US node, aka. the files hosted on AmazonS3. See https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html for all request headers.

Declared In

AVFile.h

– objectForKey:

Returns the value associated with a given key.

- (id _Nullable)objectForKey:(id)key

Parameters

key

Key.

Return Value

Value.

Discussion

Returns the value associated with a given key.

Declared In

AVFile.h

– uploadWithCompletionHandler:

Upload Method. Use default option AVFileUploadOptionCachingData.

- (void)uploadWithCompletionHandler:(void ( ^ ) ( BOOL succeeded , NSError *_Nullable error ))completionHandler

Parameters

completionHandler

Completion Handler.

Discussion

Upload Method. Use default option AVFileUploadOptionCachingData.

Declared In

AVFile.h

– uploadWithProgress:completionHandler:

Upload Method. Use default option AVFileUploadOptionCachingData.

- (void)uploadWithProgress:(void ( ^ _Nullable ) ( NSInteger number ))uploadProgressBlock completionHandler:(void ( ^ ) ( BOOL succeeded , NSError *_Nullable error ))completionHandler

Parameters

uploadProgressBlock

Upload Progress Block.

completionHandler

Completion Handler.

Discussion

Upload Method. Use default option AVFileUploadOptionCachingData.

Declared In

AVFile.h

– uploadWithOption:progress:completionHandler:

Upload Method.

- (void)uploadWithOption:(AVFileUploadOption)uploadOption progress:(void ( ^ _Nullable ) ( NSInteger number ))uploadProgressBlock completionHandler:(void ( ^ ) ( BOOL succeeded , NSError *_Nullable error ))completionHandler

Parameters

uploadOption

See AVFileUploadOption

uploadProgressBlock

Upload Progress Block.

completionHandler

Completion Handler.

Discussion

Upload Method.

Declared In

AVFile.h

– downloadWithCompletionHandler:

Download Method. Use default option AVFileDownloadOptionCachedData.

- (void)downloadWithCompletionHandler:(void ( ^ ) ( NSURL *_Nullable filePath , NSError *_Nullable error ))completionHandler

Parameters

completionHandler

Completion Handler.

Discussion

Download Method. Use default option AVFileDownloadOptionCachedData.

Declared In

AVFile.h

– downloadWithProgress:completionHandler:

Download Method. Use default option AVFileDownloadOptionCachedData.

- (void)downloadWithProgress:(void ( ^ _Nullable ) ( NSInteger number ))downloadProgressBlock completionHandler:(void ( ^ ) ( NSURL *_Nullable filePath , NSError *_Nullable error ))completionHandler

Parameters

downloadProgressBlock

Download Progress Block.

completionHandler

Completion Handler.

Discussion

Download Method. Use default option AVFileDownloadOptionCachedData.

Declared In

AVFile.h

– downloadWithOption:progress:completionHandler:

Download Method.

- (void)downloadWithOption:(AVFileDownloadOption)downloadOption progress:(void ( ^ _Nullable ) ( NSInteger number ))downloadProgressBlock completionHandler:(void ( ^ ) ( NSURL *_Nullable filePath , NSError *_Nullable error ))completionHandler

Parameters

downloadOption

See AVFileDownloadOption.

downloadProgressBlock

Download Progress Block.

completionHandler

Completion Handler.

Discussion

Download Method.

Declared In

AVFile.h

– cancelUploading

Cancel Uploading Task.

- (void)cancelUploading

Discussion

Cancel Uploading Task.

Declared In

AVFile.h

– cancelDownloading

Cancel Downloading Task.

- (void)cancelDownloading

Discussion

Cancel Downloading Task.

Declared In

AVFile.h

+ setCustomPersistentCacheDirectory:

Set a Custom Persistent Cache Directory for files. if not set, AVFile will use a default Persistent Cache Directory.

+ (void)setCustomPersistentCacheDirectory:(NSString *)directory

Parameters

directory

Custom Persistent Cache Directory.

Discussion

Set a Custom Persistent Cache Directory for files. if not set, AVFile will use a default Persistent Cache Directory.

Declared In

AVFile.h

– clearPersistentCache

Clear This file’s Persistent Cache.

- (void)clearPersistentCache

Discussion

Clear This file’s Persistent Cache.

Declared In

AVFile.h

+ clearAllPersistentCache

Clear All file’s Persistent Cache.

+ (void)clearAllPersistentCache

Discussion

Clear All file’s Persistent Cache.

Declared In

AVFile.h

– persistentCachePath

Path of This file’s Persistent Cache.

- (NSString *_Nullable)persistentCachePath

Return Value

Path.

Discussion

Path of This file’s Persistent Cache.

Declared In

AVFile.h

– deleteWithCompletionHandler:

Delete This File Object from server.

- (void)deleteWithCompletionHandler:(void ( ^ ) ( BOOL succeeded , NSError *_Nullable error ))completionHandler

Parameters

completionHandler

Completion Handler.

Discussion

Delete This File Object from server.

Declared In

AVFile.h

+ deleteWithFiles:completionHandler:

Delete File Object List from server.

+ (void)deleteWithFiles:(NSArray<AVFile*> *)files completionHandler:(void ( ^ ) ( BOOL succeeded , NSError *_Nullable error ))completionHandler

Parameters

files

File Object List

completionHandler

Completion Handler.

Discussion

Delete File Object List from server.

Declared In

AVFile.h

+ getFileWithObjectId:completionHandler:

Get File Object from server.

+ (void)getFileWithObjectId:(NSString *)objectId completionHandler:(void ( ^ ) ( AVFile *_Nullable file , NSError *_Nullable error ))completionHandler

Parameters

objectId

Object ID.

completionHandler

Completion Handler.

Discussion

Get File Object from server.

Declared In

AVFile.h

– getThumbnailURLWithScaleToFit:width:height:quality:format:

Get a thumbnail URL for image saved on Qiniu.

- (nullable NSString *)getThumbnailURLWithScaleToFit:(BOOL)scaleToFit width:(int)width height:(int)height quality:(int)quality format:(nullable NSString *)format

Parameters

scaleToFit

Scale the thumbnail and keep aspect ratio.

width

The thumbnail width.

height

The thumbnail height.

quality

The thumbnail image quality in 1 - 100.

format

The thumbnail image format such as ‘jpg’, ‘gif’, ‘png’, ‘tif’ etc.

Discussion

Get a thumbnail URL for image saved on Qiniu.

Declared In

AVFile.h

– getThumbnailURLWithScaleToFit:width:height:

Get a thumbnail URL for image saved on Qiniu.

- (nullable NSString *)getThumbnailURLWithScaleToFit:(BOOL)scaleToFit width:(int)width height:(int)height

Parameters

scaleToFit

Scale the thumbnail and keep aspect ratio.

width

The thumbnail width.

height

The thumbnail height.

Discussion

Get a thumbnail URL for image saved on Qiniu.

Declared In

AVFile.h

– getThumbnail:width:height:withBlock:

Gets a thumbnail asynchronously and calls the given block with the result.

- (void)getThumbnail:(BOOL)scaleToFit width:(int)width height:(int)height withBlock:(AVImageResultBlock)block

Parameters

scaleToFit

Scale the thumbnail and keep aspect ratio.

width

The desired width.

height

The desired height.

block

The block to execute. The block should have the following argument signature: (UIImage image, NSError error)

Discussion

Gets a thumbnail asynchronously and calls the given block with the result.

Declared In

AVFile.h

+ query

Create an AVFileQuery which returns files.

+ (AVFileQuery *)query

Discussion

Create an AVFileQuery which returns files.

Declared In

AVFile.h

– saveInBackgroundWithBlock:

- (void)saveInBackgroundWithBlock:(void ( ^ ) ( BOOL succeeded , NSError *_Nullable error ))block

– saveInBackgroundWithBlock:progressBlock:

- (void)saveInBackgroundWithBlock:(void ( ^ ) ( BOOL succeeded , NSError *_Nullable error ))block progressBlock:(void ( ^ _Nullable ) ( NSInteger number ))progressBlock

– getDataInBackgroundWithBlock:

- (void)getDataInBackgroundWithBlock:(void ( ^ ) ( NSData *_Nullable data , NSError *_Nullable error ))block

– getDataInBackgroundWithBlock:progressBlock:

- (void)getDataInBackgroundWithBlock:(void ( ^ ) ( NSData *_Nullable data , NSError *_Nullable error ))block progressBlock:(void ( ^ _Nullable ) ( NSInteger number ))progressBlock