public class ParseFile extends Object
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();
| Constructor and Description |
|---|
ParseFile(byte[] data)
Creates a new file from a byte array.
|
ParseFile(byte[] data,
String contentType)
Creates a new file from a byte array, and content type.
|
ParseFile(String name,
byte[] data)
Creates a new file from a byte array and a name.
|
ParseFile(String name,
byte[] data,
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 current network request and callbacks whether it's uploading or fetching data from
the server.
|
byte[] |
getData()
Synchronously gets the data for this object.
|
Task<byte[]> |
getDataInBackground()
Gets the data for this object in a background thread.
|
void |
getDataInBackground(GetDataCallback dataCallback)
Gets the data for this object in a background thread.
|
void |
getDataInBackground(GetDataCallback dataCallback,
ProgressCallback progressCallback)
Gets the data for this object in a background thread.
|
Task<byte[]> |
getDataInBackground(ProgressCallback progressCallback)
Gets the data for this object in a background thread.
|
String |
getName()
The filename.
|
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.
|
Task<Void> |
saveInBackground()
Saves the file to the Parse cloud in a background thread.
|
Task<Void> |
saveInBackground(ProgressCallback progressCallback)
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.
|
public ParseFile(String name, byte[] data, 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(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,
String contentType)
data - The file's data.contentType - The file's content type.public String getName()
public boolean isDirty()
public boolean isDataAvailable()
public String getUrl()
public void save()
throws ParseException
ParseExceptionpublic Task<Void> saveInBackground(ProgressCallback progressCallback)
progressCallback - A ProgressCallback that is called periodically with progress updates.public Task<Void> 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
ParseFile.getDataInBackground(com.parse.ProgressCallback) instead unless you're already in a background thread.ParseExceptionpublic Task<byte[]> getDataInBackground(ProgressCallback progressCallback)
progressCallback - A ProgressCallback that is called periodically with progress updates.public Task<byte[]> getDataInBackground()
public void getDataInBackground(GetDataCallback dataCallback, ProgressCallback progressCallback)
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)
dataCallback - A GetDataCallback that is called when the get completes.public void cancel()