Inherits from NSObject
Declared in PFFile.h

Overview

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

Tasks

Creating a PFFile

Storing Data with Parse

Getting Data from Parse

Interrupting a Transfer

  • – cancel

    Cancels the current request (whether upload or download of file data).

Properties

isDataAvailable

Whether the data is available in memory or needs to be downloaded.

@property (readonly) BOOL isDataAvailable

Discussion

Whether the data is available in memory or needs to be downloaded.

Declared In

PFFile.h

isDirty

Whether the file has been uploaded for the first time.

@property (readonly) BOOL isDirty

Discussion

Whether the file has been uploaded for the first time.

Declared In

PFFile.h

name

The name of the file. Before save is called, this is the filename given by
the user. After save is called, that name gets prefixed with a unique
identifier.

@property (assign, readonly) NSString *name

Discussion

The name of the file. Before save is called, this is the filename given by
the user. After save is called, that name gets prefixed with a unique
identifier.

Declared In

PFFile.h

url

The url of the file.

@property (assign, readonly) NSString *url

Discussion

The url of the file.

Declared In

PFFile.h

Class Methods

fileWithData:

Creates a file with given data. A name will be assigned to it by the server.

+ (id)fileWithData:(NSData *)data

Parameters

data

The contents of the new PFFile.

Return Value

A PFFile.

Discussion

Creates a file with given data. A name will be assigned to it by the server.

Declared In

PFFile.h

fileWithName:contentsAtPath:

Creates a file with the contents of another file.

+ (id)fileWithName:(NSString *)name contentsAtPath:(NSString *)path

Parameters

name

The name of the new PFFile. The file name must begin with and
alphanumeric character, and consist of alphanumeric characters, periods,
spaces, underscores, or dashes.

path

The path to the file that will be uploaded to Parse

Discussion

Creates a file with the contents of another file.

Declared In

PFFile.h

fileWithName:data:

Creates a file with given data and name.

+ (id)fileWithName:(NSString *)name data:(NSData *)data

Parameters

name

The name of the new PFFile. The file name must begin with and
alphanumeric character, and consist of alphanumeric characters, periods,
spaces, underscores, or dashes.

data

The contents of hte new PFFile.

Return Value

A PFFile.

Discussion

Creates a file with given data and name.

Declared In

PFFile.h

Instance Methods

cancel

Cancels the current request (whether upload or download of file data).

- (void)cancel

Discussion

Cancels the current request (whether upload or download of file data).

Declared In

PFFile.h

getData

Gets the data from cache if available or fetches its contents from the Parse
servers.

- (NSData *)getData

Return Value

The data. Returns nil if there was an error in fetching.

Discussion

Gets the data from cache if available or fetches its contents from the Parse
servers.

Declared In

PFFile.h

getData:

Gets the data from cache if available or fetches its contents from the Parse
servers. Sets an error if it occurs.

- (NSData *)getData:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

The data. Returns nil if there was an error in fetching.

Discussion

Gets the data from cache if available or fetches its contents from the Parse
servers. Sets an error if it occurs.

Declared In

PFFile.h

getDataInBackgroundWithBlock:

Asynchronously gets the data from cache if available or fetches its contents
from the Parse servers. Executes the given block.

- (void)getDataInBackgroundWithBlock:(PFDataResultBlock)block

Parameters

block

The block should have the following argument signature: (NSData result, NSError error)

Discussion

Asynchronously gets the data from cache if available or fetches its contents
from the Parse servers. Executes the given block.

Declared In

PFFile.h

getDataInBackgroundWithBlock:progressBlock:

Asynchronously gets the data from cache if available or fetches its contents
from the Parse servers. Executes the resultBlock upon
completion or error. Executes the progressBlock periodically with the percent progress. progressBlock will get called with 100 before resultBlock is called.

- (void)getDataInBackgroundWithBlock:(PFDataResultBlock)resultBlock progressBlock:(PFProgressBlock)progressBlock

Parameters

resultBlock

The block should have the following argument signature: (NSData result, NSError error)

progressBlock

The block should have the following argument signature: (int percentDone)

Discussion

Asynchronously gets the data from cache if available or fetches its contents
from the Parse servers. Executes the resultBlock upon
completion or error. Executes the progressBlock periodically with the percent progress. progressBlock will get called with 100 before resultBlock is called.

Declared In

PFFile.h

getDataInBackgroundWithTarget:selector:

Asynchronously gets the data from cache if available or fetches its contents
from the Parse servers.

- (void)getDataInBackgroundWithTarget:(id)target selector:(SEL)selector

Parameters

target

The object to call selector on.

selector

The selector to call. It should have the following signature: (void)callbackWithResult:(NSData )result error:(NSError )error. error will be nil on success and set if there was an error.

Discussion

Asynchronously gets the data from cache if available or fetches its contents
from the Parse servers.

Declared In

PFFile.h

getDataStream

This method is like getData but avoids ever holding the entire PFFile's
contents in memory at once. This can help applications with many large PFFiles
avoid memory warnings.

- (NSInputStream *)getDataStream

Return Value

A stream containing the data. Returns nil if there was an error in
fetching.

Discussion

This method is like getData but avoids ever holding the entire PFFile's
contents in memory at once. This can help applications with many large PFFiles
avoid memory warnings.

Declared In

PFFile.h

getDataStream:

This method is like getData: but avoids ever holding the entire PFFile's
contents in memory at once. This can help applications with many large PFFiles
avoid memory warnings. Sets an error if it occurs.

- (NSInputStream *)getDataStream:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

A stream containing the data. Returns nil if there was an error in
fetching.

Discussion

This method is like getData: but avoids ever holding the entire PFFile's
contents in memory at once. This can help applications with many large PFFiles
avoid memory warnings. Sets an error if it occurs.

Declared In

PFFile.h

getDataStreamInBackgroundWithBlock:

This method is like getDataInBackgroundWithBlock: but avoids ever holding the
entire PFFile’s contents in memory at once. This can help applications with
many large PFFiles avoid memory warnings.

- (void)getDataStreamInBackgroundWithBlock:(PFDataStreamResultBlock)block

Parameters

block

The block should have the following argument signature: (NSInputStream result, NSError error)

Discussion

This method is like getDataInBackgroundWithBlock: but avoids ever holding the
entire PFFile’s contents in memory at once. This can help applications with
many large PFFiles avoid memory warnings.

Declared In

PFFile.h

getDataStreamInBackgroundWithBlock:progressBlock:

This method is like getDataInBackgroundWithBlock:progressBlock: but avoids ever
holding the entire PFFile’s contents in memory at once. This can help
applications with many large PFFiles avoid memory warnings.

- (void)getDataStreamInBackgroundWithBlock:(PFDataStreamResultBlock)resultBlock progressBlock:(PFProgressBlock)progressBlock

Parameters

resultBlock

The block should have the following argument signature: (NSInputStream result, NSError error)

progressBlock

The block should have the following argument signature: (int percentDone)

Discussion

This method is like getDataInBackgroundWithBlock:progressBlock: but avoids ever
holding the entire PFFile’s contents in memory at once. This can help
applications with many large PFFiles avoid memory warnings.

Declared In

PFFile.h

save

Saves the file.

- (BOOL)save

Return Value

Returns whether the save succeeded.

Discussion

Saves the file.

Declared In

PFFile.h

save:

Saves the file and sets an error if it occurs.

- (BOOL)save:(NSError **)error

Parameters

error

Pointer to an NSError that will be set if necessary.

Return Value

Returns whether the save succeeded.

Discussion

Saves the file and sets an error if it occurs.

Declared In

PFFile.h

saveInBackground

Saves the file asynchronously.

- (void)saveInBackground

Discussion

Saves the file asynchronously.

Declared In

PFFile.h

saveInBackgroundWithBlock:

Saves the file asynchronously and executes the given block.

- (void)saveInBackgroundWithBlock:(PFBooleanResultBlock)block

Parameters

block

The block should have the following argument signature: (BOOL succeeded, NSError *error)

Discussion

Saves the file asynchronously and executes the given block.

Declared In

PFFile.h

saveInBackgroundWithBlock:progressBlock:

Saves the file asynchronously and executes the given resultBlock. Executes the progressBlock periodically with the percent
progress. progressBlock will get called with 100 before resultBlock is called.

- (void)saveInBackgroundWithBlock:(PFBooleanResultBlock)block progressBlock:(PFProgressBlock)progressBlock

Parameters

block

The block should have the following argument signature: (BOOL succeeded, NSError *error)

progressBlock

The block should have the following argument signature: (int percentDone)

Discussion

Saves the file asynchronously and executes the given resultBlock. Executes the progressBlock periodically with the percent
progress. progressBlock will get called with 100 before resultBlock is called.

Declared In

PFFile.h

saveInBackgroundWithTarget:selector:

Saves the file asynchronously and calls the given callback.

- (void)saveInBackgroundWithTarget:(id)target selector:(SEL)selector

Parameters

target

The object to call selector on.

selector

The selector to call. It should have the following signature: (void)callbackWithResult:(NSNumber )result error:(NSError )error. error will be nil on success and set if there was an error. [result boolValue] will tell you whether the call succeeded or not.

Discussion

Saves the file asynchronously and calls the given callback.

Declared In

PFFile.h