LuxChat  2.0
Instant messenger for iOS
Instance Methods | Class Methods | Properties | List of all members
PFFile Class Reference

#import <PFFile.h>

Inheritance diagram for PFFile:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
More...
 
(BFTask< NSNumber * > *) - saveInBackground
 
More...
 
(BFTask< NSNumber * > *) - saveInBackgroundWithProgressBlock:
 
(void) - saveInBackgroundWithBlock:
 
(void) - saveInBackgroundWithBlock:progressBlock:
 
(BFTask< NSData * > *) - getDataInBackground
 
(BFTask< NSData * > *) - getDataInBackgroundWithProgressBlock:
 
(BFTask< NSInputStream * > *) - getDataStreamInBackground
 
(BFTask< NSInputStream * > *) - getDataDownloadStreamInBackground
 
(BFTask< NSInputStream * > *) - getDataStreamInBackgroundWithProgressBlock:
 
(BFTask< NSInputStream * > *) - getDataDownloadStreamInBackgroundWithProgressBlock:
 
(void) - getDataInBackgroundWithBlock:
 
(void) - getDataStreamInBackgroundWithBlock:
 
(void) - getDataInBackgroundWithBlock:progressBlock:
 
(void) - getDataStreamInBackgroundWithBlock:progressBlock:
 
(BFTask< NSString * > *) - getFilePathInBackground
 
(BFTask< NSString * > *) - getFilePathInBackgroundWithProgressBlock:
 
(void) - getFilePathInBackgroundWithBlock:
 
(void) - getFilePathInBackgroundWithBlock:progressBlock:
 
(void) - cancel
 
More...
 
(BFTask *) - clearCachedDataInBackground
 
More...
 
(void) - saveInBackgroundWithTarget:selector:
 
More...
 
(void) - getDataInBackgroundWithTarget:selector:
 
More...
 
(BOOL) - PF_SWIFT_UNAVAILABLE
 
More...
 
(nullable NSData *) - PF_SWIFT_UNAVAILABLE
 
(nullable NSInputStream *) - PF_SWIFT_UNAVAILABLE
 
(BOOL) - save:
 
(nullable NSData *) - getData:
 
(nullable NSInputStream *) - getDataStream:
 

Class Methods

(instancetype) + NS_UNAVAILABLE
 
(nullable instancetype) + fileWithData:
 
(nullable instancetype) + fileWithName:data:
 
(nullable instancetype) + fileWithName:contentsAtPath:
 
(nullable instancetype) + fileWithName:contentsAtPath:error:
 
(nullable instancetype) + fileWithName:data:contentType:
 
(nullable instancetype) + fileWithName:data:contentType:error:
 
(instancetype) + fileWithData:contentType:
 
(BFTask *) + clearAllCachedDataInBackground
 

Properties

NSString * name
 
More...
 
NSString * url
 
BOOL dirty
 
BOOL dataAvailable
 
More...
 

Detailed Description

Copyright (c) 2015-present, Parse, LLC. All rights reserved.

This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. An additional grant of patent rights can be found in the PATENTS file in the same directory. PFFile representes 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.

Method Documentation

- (void) cancel



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

+ (BFTask *) clearAllCachedDataInBackground

Clears all cached data for all downloaded files.

Returns
The task, with the result set to nil if the operation succeeds.
- (BFTask *) clearCachedDataInBackground



Clears all cached data for this file.

Returns
The task, with the result set to nil if the operation succeeds.
+ (nullable instancetype) fileWithData: (NSData *)  data

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

Parameters
dataThe contents of the new PFFile.
Returns
A new PFFile.
+ (instancetype) fileWithData: (NSData *)  data
contentType: (nullable NSString *)  contentType 

Creates a file with given data and content type.

Parameters
dataThe contents of the new PFFile.
contentTypeRepresents MIME type of the data.
Returns
A new PFFile object.
+ (nullable instancetype) fileWithName: (nullable NSString *)  name
contentsAtPath: (NSString *)  PF_SWIFT_UNAVAILABLE 

Creates a file with the contents of another file.

Warning
This method raises an exception if the file at path is not accessible or if there is not enough disk space left.
Parameters
nameThe name of the new PFFile. The file name must begin with and alphanumeric character, and consist of alphanumeric characters, periods, spaces, underscores, or dashes.
pathThe path to the file that will be uploaded to Parse.
Returns
A new PFFile instance.
+ (nullable instancetype) fileWithName: (nullable NSString *)  name
contentsAtPath: (NSString *)  path
error: (NSError **)  error 

Creates a file with the contents of another file.

Parameters
nameThe name of the new PFFile. The file name must begin with and alphanumeric character, and consist of alphanumeric characters, periods, spaces, underscores, or dashes.
pathThe path to the file that will be uploaded to Parse.
errorOn input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Returns
A new PFFile instance or nil if the error occured.
+ (nullable instancetype) fileWithName: (nullable NSString *)  name
data: (NSData *)  data 

Creates a file with given data and name.

Parameters
nameThe name of the new PFFile. The file name must begin with and alphanumeric character, and consist of alphanumeric characters, periods, spaces, underscores, or dashes.
dataThe contents of the new PFFile.
Returns
A new PFFile object.
+ (nullable instancetype) fileWithName: (nullable NSString *)  name
data: (NSData *)  data
contentType: (nullable NSString *)  PF_SWIFT_UNAVAILABLE 

Creates a file with given data, name and content type.

Warning
This method raises an exception if the data supplied is not accessible or could not be saved.
Parameters
nameThe name of the new PFFile. The file name must begin with and alphanumeric character, and consist of alphanumeric characters, periods, spaces, underscores, or dashes.
dataThe contents of the new PFFile.
contentTypeRepresents MIME type of the data.
Returns
A new PFFile instance.
+ (nullable instancetype) fileWithName: (nullable NSString *)  name
data: (NSData *)  data
contentType: (nullable NSString *)  contentType
error: (NSError **)  error 

Creates a file with given data, name and content type.

Parameters
nameThe name of the new PFFile. The file name must begin with and alphanumeric character, and consist of alphanumeric characters, periods, spaces, underscores, or dashes.
dataThe contents of the new PFFile.
contentTypeRepresents MIME type of the data.
errorOn input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Returns
A new PFFile instance or nil if the error occured.
- (nullable NSData *) getData: (NSError **)  error

Synchronously* gets the data from cache if available or fetches its contents from the network. Sets an error if it occurs.

Parameters
errorPointer to an NSError that will be set if necessary.
Returns
The NSData object containing file data. Returns nil if there was an error in fetching.

Provided by category PFFile(Synchronous).

- (BFTask<NSInputStream *> *) getDataDownloadStreamInBackground

This method is like -getDataStreamInBackground, but yields a live-updating stream.

Instead of -getDataStream, which yields a stream that can be read from only after the request has completed, this method gives you a stream directly written to by the HTTP session. As this stream is not pre-buffered, it is strongly advised to use the NSStreamDelegate methods, in combination with a run loop, to consume the data in the stream, to do proper async file downloading.

Note
You MUST open this stream before reading from it.
Do NOT call waitUntilFinished on this task from the main thread. It may result in a deadlock.
Returns
A task that produces a live stream that is being written to with the data from the server.
- (BFTask<NSInputStream *> *) getDataDownloadStreamInBackgroundWithProgressBlock: (nullable PFProgressBlock)  progressBlock

This method is like -getDataStreamInBackgroundWithProgressBlock:, but yields a live-updating stream.

Instead of -getDataStream, which yields a stream that can be read from only after the request has completed, this method gives you a stream directly written to by the HTTP session. As this stream is not pre-buffered, it is strongly advised to use the NSStreamDelegate methods, in combination with a run loop, to consume the data in the stream, to do proper async file downloading.

Note
You MUST open this stream before reading from it.
Do NOT call waitUntilFinished on this task from the main thread. It may result in a deadlock.
Parameters
progressBlockThe block should have the following argument signature: ^(int percentDone)
Returns
A task that produces a live stream that is being written to with the data from the server.
- (BFTask<NSData *> *) getDataInBackground

This method is like -getData but it fetches asynchronously to avoid blocking the current thread.

See also
getData
Returns
The task, that encapsulates the work being done.
- (void) getDataInBackgroundWithBlock: (nullable PFDataResultBlock)  block

Asynchronously* gets the data from cache if available or fetches its contents from the network.

Parameters
blockThe block should have the following argument signature: ^(NSData *result, NSError *error)
- (void) getDataInBackgroundWithBlock: (nullable PFDataResultBlock)  resultBlock
progressBlock: (nullable PFProgressBlock)  progressBlock 

Asynchronously* gets the data from cache if available or fetches its contents from the network.

This method will execute the progressBlock periodically with the percent progress. progressBlock will get called with 100 before resultBlock is called.

Parameters
resultBlockThe block should have the following argument signature: ^(NSData *result, NSError *error)
progressBlockThe block should have the following argument signature: ^(int percentDone)
- (BFTask<NSData *> *) getDataInBackgroundWithProgressBlock: (nullable PFProgressBlock)  progressBlock

This method is like -getData but it fetches asynchronously to avoid blocking the current thread.

This can help applications with many large files avoid memory warnings.

See also
getData
Parameters
progressBlockThe block should have the following argument signature: ^(int percentDone)
Returns
The task, that encapsulates the work being done.
- (void) getDataInBackgroundWithTarget: (nullable id)  target
selector: ("Please use `PFFile.-getDataInBackgroundWithBlock:` instead.")  PARSE_DEPRECATED 



Asynchronously* gets the data from cache if available or fetches its contents from the network.

Parameters
targetThe object to call selector on.
selectorThe 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.
Deprecated:
Please use PFFile.-getDataInBackgroundWithBlock: instead.

Provided by category PFFile(Deprecated).

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

This method is like -getData but avoids ever holding the entire PFFile contents in memory at once.

Parameters
errorPointer to an NSError that will be set if necessary.
Returns
A stream containing the data. Returns nil if there was an error in fetching.

Provided by category PFFile(Synchronous).

- (BFTask<NSInputStream *> *) getDataStreamInBackground

This method is like -getDataInBackground but avoids ever holding the entire PFFile contents in memory at once.

This can help applications with many large files avoid memory warnings.

Returns
The task, that encapsulates the work being done.
- (void) getDataStreamInBackgroundWithBlock: (nullable PFDataStreamResultBlock)  block

This method is like -getDataInBackgroundWithBlock: but avoids ever holding the entire PFFile contents in memory at once.

This can help applications with many large files avoid memory warnings.

Parameters
blockThe block should have the following argument signature: (NSInputStream *result, NSError *error)
- (void) getDataStreamInBackgroundWithBlock: (nullable PFDataStreamResultBlock)  resultBlock
progressBlock: (nullable PFProgressBlock)  progressBlock 

This method is like -getDataInBackgroundWithBlock:progressBlock: but avoids ever holding the entire PFFile contents in memory at once.

This can help applications with many large files avoid memory warnings.

Parameters
resultBlockThe block should have the following argument signature: ^(NSInputStream *result, NSError *error).
progressBlockThe block should have the following argument signature: ^(int percentDone).
- (BFTask<NSInputStream *> *) getDataStreamInBackgroundWithProgressBlock: (nullable PFProgressBlock)  progressBlock

This method is like -getDataInBackground but avoids ever holding the entire PFFile contents in memory at once.

This can help applications with many large files avoid memory warnings.

Parameters
progressBlockThe block should have the following argument signature: ^(int percentDone)
Returns
The task, that encapsulates the work being done.
- (BFTask<NSString *> *) getFilePathInBackground

Asynchronously* gets the file path for file from cache if available or fetches its contents from the network.

Note
The file path may change between versions of SDK.
If you overwrite the contents of the file at returned path it will persist those change until the file cache is cleared.
Returns
The task, with the result set to NSString representation of a file path.
- (void) getFilePathInBackgroundWithBlock: (nullable PFFilePathResultBlock)  block

Asynchronously* gets the file path for file from cache if available or fetches its contents from the network.

Note
The file path may change between versions of SDK.
If you overwrite the contents of the file at returned path it will persist those change until the file cache is cleared.
Parameters
blockThe block should have the following argument signature: ^(NSString *filePath, NSError *error).
- (void) getFilePathInBackgroundWithBlock: (nullable PFFilePathResultBlock)  block
progressBlock: (nullable PFProgressBlock)  progressBlock 

Asynchronously* gets the file path for file from cache if available or fetches its contents from the network.

Note
The file path may change between versions of SDK.
If you overwrite the contents of the file at returned path it will persist those change until the file cache is cleared.
Parameters
blockThe block should have the following argument signature: ^(NSString *filePath, NSError *error).
progressBlockThe block should have the following argument signature: ^(int percentDone).
- (BFTask<NSString *> *) getFilePathInBackgroundWithProgressBlock: (nullable PFProgressBlock)  progressBlock

Asynchronously* gets the file path for file from cache if available or fetches its contents from the network.

Note
The file path may change between versions of SDK.
If you overwrite the contents of the file at returned path it will persist those change until the file cache is cleared.
Parameters
progressBlockThe block should have the following argument signature: ^(int percentDone).
Returns
The task, with the result set to NSString representation of a file path.
- (instancetype) NS_UNAVAILABLE



- (nullable NSInputStream *) PF_SWIFT_UNAVAILABLE

This method is like -getData but avoids ever holding the entire PFFile contents in memory at once.

This can help applications with many large files avoid memory warnings.

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

Provided by category PFFile(Synchronous).

- (nullable NSData *) PF_SWIFT_UNAVAILABLE

Synchronously* gets the data from cache if available or fetches its contents from the network.

Returns
The NSData object containing file data. Returns nil if there was an error in fetching.

Provided by category PFFile(Synchronous).

- (BOOL) PF_SWIFT_UNAVAILABLE



Saves the file synchronously.

Returns
Returns whether the save succeeded.

Provided by category PFFile(Synchronous).

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

Saves the file synchronously and sets an error if it occurs.

Parameters
errorPointer to an NSError that will be set if necessary.
Returns
Returns whether the save succeeded.

Provided by category PFFile(Synchronous).

- (BFTask<NSNumber *> *) saveInBackground



Saves the file asynchronously.

Returns
The task, that encapsulates the work being done.
- (void) saveInBackgroundWithBlock: (nullable PFBooleanResultBlock)  block

Saves the file asynchronously and executes the given block.

Parameters
blockThe block should have the following argument signature: ^(BOOL succeeded, NSError *error).
- (void) saveInBackgroundWithBlock: (nullable PFBooleanResultBlock)  block
progressBlock: (nullable PFProgressBlock)  progressBlock 

Saves the file asynchronously and executes the given block.

This method will execute the progressBlock periodically with the percent progress. progressBlock will get called with 100 before resultBlock is called.

Parameters
blockThe block should have the following argument signature: ^(BOOL succeeded, NSError *error)
progressBlockThe block should have the following argument signature: ^(int percentDone)
- (BFTask<NSNumber *> *) saveInBackgroundWithProgressBlock: (nullable PFProgressBlock)  progressBlock

Saves the file asynchronously

Parameters
progressBlockThe block should have the following argument signature: ^(int percentDone)
Returns
The task, that encapsulates the work being done.
- (void) saveInBackgroundWithTarget: (nullable id)  target
selector: ("Please use `PFFile.-saveInBackgroundWithBlock:` instead.")  PARSE_DEPRECATED 



Saves the file asynchronously and invokes the given selector on a target.

Parameters
targetThe object to call selector on.
selectorThe 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.
Deprecated:
Please use PFFile.-saveInBackgroundWithBlock: instead.

Provided by category PFFile(Deprecated).

Property Documentation

- (BOOL) dataAvailable
readnonatomicassign



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

Provided by category PFFile(Synchronous).

- (BOOL) dirty
readnonatomicassign

Whether the file has been uploaded for the first time.

- (NSString*) name
readnonatomiccopy



The name of the file.

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

- (NSString*) url
readnonatomiccopy

The url of the file.


The documentation for this class was generated from the following file: