java.lang.Object | ||
↳ | com.kinvey.java.File | |
↳ | com.kinvey.android.AsyncFile |
Wraps the com.kinvey.java.File public methods in asynchronous functionality using native Android AsyncTask.
This functionality can be accessed through the file()
convenience method.
The callback mechanism for this api is extended to include the progressChanged(com.kinvey.java.core.MediaHttpUploader)
method, which receives notifications as the upload process transitions through and progresses with the upload.
process.
Sample usage:
mKinveyClient.file().upload(file, new UploaderProgressListener() {
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
delete(String filename, KinveyClientCallback<Void> callback)
Deletes the given file from the Kinvey file service.
| ||||||||||
void |
download(String filename, OutputStream out, DownloaderProgressListener listener)
Download a given file from the Kinvey file service.
| ||||||||||
void |
getDownloadUrl(String fileName, KinveyClientCallback<UriLocResponse> callback)
Constructs a request to retrieve a temporary url for purposes of downloading a given file already known to Kinvey.
| ||||||||||
void |
getUploadUrl(String fileName, KinveyClientCallback<UriLocResponse> callback)
Constructs a request to retrieve a temporary url for purposes of uploading a given file.
| ||||||||||
void |
upload(File file, UploaderProgressListener listener)
Uploads a given file and its contents to the Kinvey file service.
| ||||||||||
void |
upload(String name, InputStream inputStream, UploaderProgressListener listener)
Uploads the contents of the stream to the Kinvey file service endpoint.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Deletes the given file from the Kinvey file service.
filename | the name of used in metadata to refer to the file |
---|---|
callback | an implementation of a client callback to get results on the UI thread from the async call. |
Download a given file from the Kinvey file service.
The UI thread can receive updates on the status by passing in a progress listener.
public static class MyDownloadProgressListener implements DownloaderProgressListener { public void progressChanged(MediaHttpDownloader downloader) throws IOException { switch (downloader.getDownloadState()) { case DOWNLOAD_IN_PROGRESS: Log.i(TAG, "Download in progress"); Log.i(TAG, "Download percentage: " + downloader.getProgress()); break; case DOWNLOAD_COMPLETE: Log.i(TAG, "Download Completed!"); break; } } public void onSuccess(Void result) {} public void onFailure(Throwable error) { Log.e(TAG, "Upload failed", error); } }
filename | the name used in metadata for downloadable file. |
---|---|
out | a java.io.OutputStream object. |
listener | an implementation of a client listener to get results on the UI thread from the async call. |
Constructs a request to retrieve a temporary url for purposes of downloading a given file already known to Kinvey.
The url expires within 60 secs. of calling execute on the request returned.
fileName | name of the file for which kinvey service is aware |
---|---|
callback | an implementation of a client callback to get results on the UI thread from the async call. |
Constructs a request to retrieve a temporary url for purposes of uploading a given file.
The url expires within 60 secs. of calling execute on the request returned.
fileName | the name of the file used in metadata |
---|---|
callback | an implementation of a client callback to get results on the UI thread from the async call. |
Uploads a given file and its contents to the Kinvey file service.
The UI thread can receive updates on the status by passing in a progress listener.
Sample usage:
public static class MyUploadProgressListener implements UploaderProgressListener { public void progressChanged(MediaHttpUploader uploader) throws IOException { switch (uploader.getUploadState()) { case INITIATION_STARTED: Log.i(TAG, "Initiation Started"); break; case INITIATION_COMPLETE: Log.i(TAG, "Initiation Completed"); break; case DOWNLOAD_IN_PROGRESS: Log.i(TAG, "Upload in progress"); Log.i(TAG, "Upload percentage: " + uploader.getProgress()); break; case DOWNLOAD_COMPLETE: Log.i(TAG, "Upload Completed!"); break; } } public void onSuccess(Void result) {} public void onFailure(Throwable error) { Log.e(TAG, "Upload failed", error); } }
file | the file to be uploaded |
---|---|
listener | an implementation of a client listener that gets notifications on the UI thread from the underlying thread. |
Uploads the contents of the stream to the Kinvey file service endpoint.
name | name to refer to the blob when stored with the file service endpoint |
---|---|
inputStream | stream to be uploaded |
listener | an implementation of a client listener to get results on the UI thread from the async call. |