public class CloudFile extends Object
Title: Abstract wrapper for File objects
CloudFile is an object that represents an arbitrary file format, can save and retrieve these from CloudBoost
| Constructor and Description |
|---|
CloudFile(Blob fileObj)
Constructor that builds CloudFile Object from a
Blob |
CloudFile(File fileObj)
Constructor that builds a CloudFile object from
File and tries to guess the mimetype |
CloudFile(File fileObj,
String contentType)
Constructor that builds a CloudFile object from
File and content type of the file |
CloudFile(JSONObject jsonObject) |
CloudFile(String url)
A Constructor that takes the URL of a file and downloads it to create a CloudFile Object
|
CloudFile(String fileName,
Object data,
String type)
Constructor that builds a CloudFile object out of arbitrary data
|
| Modifier and Type | Method and Description |
|---|---|
void |
delete(CloudStringCallback callbackObject)
deletes a saved CloudFile
|
void |
fetch(CloudFileArrayCallback callback)
fetches this file from the database
|
ACL |
getAcl()
returns the ACL object representing the access rights on this file
|
JSONObject |
getDocument()
returns the raw JSONObject wrapped by this class, only make direct changes to the underlying JSONObject
if you absolutely know what you are doing
|
void |
getFileContent(ObjectCallback callback)
returns the file content as an object
|
String |
getFileName()
returns the name of the file
|
int |
getFileSize()
Returns the size of the file in Bytes
|
String |
getFileType()
returns the mime type of the file as a
String |
String |
getFileUrl()
returns the URL of the file as saved in cloudboost, unsaved files have no URL's
|
String |
getId()
returns the Id assigned to this file after saving, an unsaved CloudFile object has no Id
|
static void |
main(String[] args) |
void |
save(CloudFileCallback callbackObject)
Makes an HTTP POST request to upload the file and save all attributes to CloudBoost
|
void |
save(CloudFileCallback callbackObject,
FileUploadCallback uploadCallback)
Makes an HTTP POST request to upload the file and save all attributes to CloudBoost
|
void |
setAcl(ACL acl)
replaces the existing ACL object
|
void |
setDocument(JSONObject document) |
void |
setFileName(String name)
Gives the file a name as should be saved in CloudBoost
|
void |
setFileType(String type)
Changes the type of the file to the given String
|
public CloudFile(File fileObj, String contentType) throws CloudException
File and content type of the filefileObj - a Java file objectcontentType - String representing content/mime type of this fileCloudExceptionpublic CloudFile(File fileObj) throws CloudException
File and tries to guess the mimetypefileObj - a java file objectCloudExceptionpublic CloudFile(Blob fileObj) throws CloudException
BlobfileObj - CloudExceptionpublic CloudFile(String url) throws CloudException
url - CloudExceptionpublic CloudFile(String fileName, Object data, String type) throws CloudException
fileName - the name under which the file should be storeddata - the content of the filetype - mimetype of the fileCloudExceptionpublic CloudFile(JSONObject jsonObject)
public void setDocument(JSONObject document)
public String getId()
public void setFileType(String type)
type - mime type of filepublic String getFileType()
Stringpublic String getFileUrl()
public void setFileName(String name)
name - the name the file should be saved underpublic String getFileName()
public int getFileSize()
public void save(CloudFileCallback callbackObject, FileUploadCallback uploadCallback) throws CloudException, IOException, JSONException
callbackObject - callback to be triggered when the call has completeduploadCallback - callback interface that returns in realtime the percent of file uploadedCloudExceptionIOExceptionJSONExceptionpublic void save(CloudFileCallback callbackObject) throws CloudException, IOException, JSONException
callbackObject - callback to be triggered when the call has completedCloudExceptionIOExceptionJSONExceptionpublic JSONObject getDocument()
public void delete(CloudStringCallback callbackObject) throws CloudException
callbackObject - callback triggered when the call completesCloudExceptionpublic void getFileContent(ObjectCallback callback)
callback - public ACL getAcl()
public void setAcl(ACL acl)
acl - new ACL objectpublic void fetch(CloudFileArrayCallback callback) throws CloudException
callback - CloudExceptionpublic static void main(String[] args) throws CloudException, JSONException, IOException
CloudExceptionJSONExceptionIOExceptionCopyright © 2016. All rights reserved.