public class ParseFile
extends java.lang.Object
implements android.os.Parcelable
ParseFile is a local representation of a file that is saved to the Parse cloud.
The workflow is to construct a ParseFile with data and optionally a filename. Then save
it and set it as a field on a ParseObject.
Example:
ParseFile file = new ParseFile("hello".getBytes());
file.save();
ParseObject object = new ParseObject("TestObject");
object.put("file", file);
object.save();
| Modifier and Type | Field and Description |
|---|---|
static android.os.Parcelable.Creator<ParseFile> |
CREATOR |
| Modifier | Constructor and Description |
|---|---|
|
ParseFile(byte[] data)
Creates a new file from a byte array.
|
|
ParseFile(byte[] data,
java.lang.String contentType)
Creates a new file from a byte array, and content type.
|
|
ParseFile(java.io.File file)
Creates a new file from a file pointer.
|
|
ParseFile(java.io.File file,
java.lang.String contentType)
Creates a new file from a file pointer, and content type.
|
protected |
ParseFile(android.os.Parcel source)
Creates a new file instance from a
Parcel source. |
|
ParseFile(java.lang.String name,
byte[] data)
Creates a new file from a byte array and a name.
|
|
ParseFile(java.lang.String name,
byte[] data,
java.lang.String contentType)
Creates a new file from a byte array, file name, and content type.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels the operations for this
ParseFile if they are still in the task queue. |
int |
describeContents() |
byte[] |
getData()
Synchronously gets the data from cache if available or fetches its content from the network.
|
<any> |
getDataInBackground()
Asynchronously gets the data from cache if available or fetches its content from the network.
|
void |
getDataInBackground(GetDataCallback dataCallback)
Asynchronously gets the data from cache if available or fetches its content from the network.
|
void |
getDataInBackground(GetDataCallback dataCallback,
ProgressCallback progressCallback)
Asynchronously gets the data from cache if available or fetches its content from the network.
|
<any> |
getDataInBackground(ProgressCallback progressCallback)
Asynchronously gets the data from cache if available or fetches its content from the network.
|
java.io.InputStream |
getDataStream()
Synchronously gets the data stream from cached file if available or fetches its content from
the network, saves the content as cached file and returns the data stream of the cached file.
|
<any> |
getDataStreamInBackground()
Asynchronously gets the data stream from cached file if available or fetches its content from
the network, saves the content as cached file and returns the data stream of the cached file.
|
void |
getDataStreamInBackground(GetDataStreamCallback dataStreamCallback)
Asynchronously gets the data stream from cached file if available or fetches its content from
the network, saves the content as cached file and returns the data stream of the cached file.
|
void |
getDataStreamInBackground(GetDataStreamCallback dataStreamCallback,
ProgressCallback progressCallback)
Asynchronously gets the data stream from cached file if available or fetches its content from
the network, saves the content as cached file and returns the data stream of the cached file.
|
<any> |
getDataStreamInBackground(ProgressCallback progressCallback)
Asynchronously gets the data stream from cached file if available or fetches its content from
the network, saves the content as cached file and returns the data stream of the cached file.
|
java.io.File |
getFile()
Synchronously gets the file pointer from cache if available or fetches its content from the
network.
|
<any> |
getFileInBackground()
Asynchronously gets the file pointer from cache if available or fetches its content from the
network.
|
void |
getFileInBackground(GetFileCallback fileCallback)
Asynchronously gets the file pointer from cache if available or fetches its content from the
network.
|
void |
getFileInBackground(GetFileCallback fileCallback,
ProgressCallback progressCallback)
Asynchronously gets the file pointer from cache if available or fetches its content from the
network.
|
<any> |
getFileInBackground(ProgressCallback progressCallback)
Asynchronously gets the file pointer from cache if available or fetches its content from the
network.
|
java.lang.String |
getName()
The filename.
|
java.lang.String |
getUrl()
This returns the url of the file.
|
boolean |
isDataAvailable()
Whether the file has available data.
|
boolean |
isDirty()
Whether the file still needs to be saved.
|
void |
save()
Saves the file to the Parse cloud synchronously.
|
<any> |
saveInBackground()
Saves the file to the Parse cloud in a background thread.
|
<any> |
saveInBackground(ProgressCallback uploadProgressCallback)
Saves the file to the Parse cloud in a background thread.
|
void |
saveInBackground(SaveCallback callback)
Saves the file to the Parse cloud in a background thread.
|
void |
saveInBackground(SaveCallback saveCallback,
ProgressCallback progressCallback)
Saves the file to the Parse cloud in a background thread.
|
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public static final android.os.Parcelable.Creator<ParseFile> CREATOR
public ParseFile(java.io.File file)
file - The file.public ParseFile(java.io.File file,
java.lang.String contentType)
file - The file.contentType - The file's content type.public ParseFile(java.lang.String name,
byte[] data,
java.lang.String contentType)
name - The file's name, ideally with extension. The file name must begin with an alphanumeric
character, and consist of alphanumeric characters, periods, spaces, underscores, or
dashes.data - The file's data.contentType - The file's content type.public ParseFile(byte[] data)
data - The file's data.public ParseFile(java.lang.String name,
byte[] data)
name - The file's name, ideally with extension. The file name must begin with an alphanumeric
character, and consist of alphanumeric characters, periods, spaces, underscores, or
dashes.data - The file's data.public ParseFile(byte[] data,
java.lang.String contentType)
data - The file's data.contentType - The file's content type.protected ParseFile(android.os.Parcel source)
Parcel source. This is used when unparceling
a non-dirty ParseFile. Subclasses that need Parcelable behavior should provide their own
Parcelable.Creator and override this constructor.source - the source Parcelpublic java.lang.String getName()
public boolean isDirty()
public boolean isDataAvailable()
public java.lang.String getUrl()
public void save()
throws ParseException
ParseExceptionpublic <any> saveInBackground(ProgressCallback uploadProgressCallback)
uploadProgressCallback - A ProgressCallback that is called periodically with progress updates.public <any> saveInBackground()
public void saveInBackground(SaveCallback saveCallback, ProgressCallback progressCallback)
saveCallback - A SaveCallback that gets called when the save completes.progressCallback - A ProgressCallback that is called periodically with progress updates.public void saveInBackground(SaveCallback callback)
callback - A SaveCallback that gets called when the save completes.public byte[] getData()
throws ParseException
getDataInBackground() instead unless you're already in a
background thread.ParseExceptionpublic <any> getDataInBackground(ProgressCallback progressCallback)
ProgressCallback will be called periodically with progress updates.progressCallback - A ProgressCallback that is called periodically with progress updates.public <any> getDataInBackground()
public void getDataInBackground(GetDataCallback dataCallback, ProgressCallback progressCallback)
ProgressCallback will be called periodically with progress updates.
A GetDataCallback will be called when the get completes.dataCallback - A GetDataCallback that is called when the get completes.progressCallback - A ProgressCallback that is called periodically with progress updates.public void getDataInBackground(GetDataCallback dataCallback)
GetDataCallback will be called when the get completes.dataCallback - A GetDataCallback that is called when the get completes.public java.io.File getFile()
throws ParseException
getFileInBackground() instead unless you're already
in a background thread.
Note: The File location may change without notice and should not be
stored to be accessed later.ParseExceptionpublic <any> getFileInBackground(ProgressCallback progressCallback)
ProgressCallback will be called periodically with progress updates.
Note: The File location may change without notice and should not be
stored to be accessed later.progressCallback - A ProgressCallback that is called periodically with progress updates.public <any> getFileInBackground()
File location may change without notice and should not be
stored to be accessed later.public void getFileInBackground(GetFileCallback fileCallback, ProgressCallback progressCallback)
GetFileCallback will be called when the get completes.
The ProgressCallback will be called periodically with progress updates.
The ProgressCallback is guaranteed to be called with 100 before the
GetFileCallback is called.
Note: The File location may change without notice and should not be
stored to be accessed later.fileCallback - A GetFileCallback that is called when the get completes.progressCallback - A ProgressCallback that is called periodically with progress updates.public void getFileInBackground(GetFileCallback fileCallback)
GetFileCallback will be called when the get completes.
Note: The File location may change without notice and should not be
stored to be accessed later.fileCallback - A GetFileCallback that is called when the get completes.public java.io.InputStream getDataStream()
throws ParseException
getDataStreamInBackground(com.parse.ProgressCallback) instead unless you're already in a
background thread.ParseExceptionpublic <any> getDataStreamInBackground(ProgressCallback progressCallback)
ProgressCallback will be called periodically with progress updates.progressCallback - A ProgressCallback that is called periodically with progress updates.public <any> getDataStreamInBackground()
public void getDataStreamInBackground(GetDataStreamCallback dataStreamCallback, ProgressCallback progressCallback)
GetDataStreamCallback will be called when the get completes. The
ProgressCallback will be called periodically with progress updates. The
ProgressCallback is guaranteed to be called with 100 before
GetDataStreamCallback is called.dataStreamCallback - A GetDataStreamCallback that is called when the get completes.progressCallback - A ProgressCallback that is called periodically with progress updates.public void getDataStreamInBackground(GetDataStreamCallback dataStreamCallback)
GetDataStreamCallback will be called when the get completes.dataStreamCallback - A GetDataStreamCallback that is called when the get completes.public void cancel()
ParseFile if they are still in the task queue. However,
if a network request has already been started for an operation, the network request will not
be canceled.public int describeContents()
describeContents in interface android.os.Parcelablepublic void writeToParcel(android.os.Parcel dest,
int flags)
writeToParcel in interface android.os.Parcelable