public class BaasFile extends BaasObject implements android.os.Parcelable
A file is an entity that can be stored on the server. Unlike documents files do not dictate a format for their content, but they can have optionally json attached data.
Files can be created, stored and retrieved from the server either synchronously or asynchronously, through the provided methods.
A BaasFile does not represent the content of the file, but an handle to the actual content. The actual content can be obtained through a streaming api.
Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator<BaasFile> |
CREATOR |
Constructor and Description |
---|
BaasFile() |
BaasFile(JsonObject attachedData) |
Modifier and Type | Method and Description |
---|---|
RequestToken |
delete(BaasHandler<java.lang.Void> handler) |
RequestToken |
delete(int flags,
BaasHandler<java.lang.Void> handler) |
static RequestToken |
delete(java.lang.String id,
BaasHandler<java.lang.Void> handler) |
static RequestToken |
delete(java.lang.String id,
int flags,
BaasHandler<java.lang.Void> handler) |
BaasResult<java.lang.Void> |
deleteSync() |
static BaasResult<java.lang.Void> |
deleteSync(java.lang.String id) |
int |
describeContents() |
RequestToken |
download(java.lang.String path,
BaasHandler<android.util.Pair<BaasFile,java.lang.String>> handler) |
RequestToken |
extractedContent(BaasHandler<java.lang.String> handler) |
RequestToken |
extractedContent(int flags,
BaasHandler<java.lang.String> handler) |
BaasResult<java.lang.String> |
extractedContentSync() |
static RequestToken |
fetch(java.lang.String id,
BaasHandler<BaasFile> handler) |
static RequestToken |
fetch(java.lang.String id,
int flags,
BaasHandler<BaasFile> handler) |
static RequestToken |
fetchAll(BaasHandler<java.util.List<BaasFile>> handler) |
static RequestToken |
fetchAll(BaasQuery.Criteria filter,
BaasHandler<java.util.List<BaasFile>> handler) |
static RequestToken |
fetchAll(BaasQuery.Criteria filter,
int flags,
BaasHandler<java.util.List<BaasFile>> handler) |
static BaasResult<java.util.List<BaasFile>> |
fetchAllSync() |
static BaasResult<java.util.List<BaasFile>> |
fetchAllSync(BaasQuery.Criteria filter) |
static RequestToken |
fetchStream(java.lang.String id,
BaasHandler<BaasFile> handler) |
static BaasResult<BaasFile> |
fetchSync(java.lang.String id) |
JsonObject |
getAttachedData() |
java.lang.String |
getAuthor()
The username of the owner of this object, or null if this object is new.
|
long |
getContentLength() |
java.lang.String |
getContentType() |
java.lang.String |
getCreationDate()
The date this object was created on the server, or null if the object is new.
|
byte[] |
getData() |
java.lang.String |
getId()
The id of this object on the server.
|
JsonObject |
getMetadata()
Retrieves the metadata associated with this file
coomputed by the server.
|
android.net.Uri |
getStreamUri() |
long |
getVersion()
The version number of this object.
|
RequestToken |
grant(Grant grant,
java.lang.String username,
int flags,
BaasHandler<java.lang.Void> handler)
Asynchronously grants the access
grant to this object to username . |
RequestToken |
grantAll(Grant grant,
java.lang.String role,
int flags,
BaasHandler<java.lang.Void> handler)
Asynchronously grants the access
grant to this object to users with role . |
BaasResult<java.lang.Void> |
grantAllSync(Grant grant,
java.lang.String role)
Synchronously grants the acces
grant to this object to all users in role |
BaasResult<java.lang.Void> |
grantSync(Grant grant,
java.lang.String user)
Synchronously grants the access
grant to this object to username . |
boolean |
isDirty() |
boolean |
isDocument() |
boolean |
isFile() |
RequestToken |
refresh(BaasHandler<BaasFile> handler) |
RequestToken |
refresh(int flags,
BaasHandler<BaasFile> handler) |
BaasResult<BaasFile> |
refreshSync() |
RequestToken |
revoke(Grant grant,
java.lang.String username,
int flags,
BaasHandler<java.lang.Void> handler)
Asynchronously revoke the access
grant to this object to username . |
RequestToken |
revokeAll(Grant grant,
java.lang.String role,
int flags,
BaasHandler<java.lang.Void> handler)
Asynchronously revokes the access
grant to this object from users with role . |
BaasResult<java.lang.Void> |
revokeAllSync(Grant grant,
java.lang.String role)
Synchronously revokes the acces
grant to this object from all users in role |
BaasResult<java.lang.Void> |
revokeSync(Grant grant,
java.lang.String user)
Synchronously revokes the access
grant to this object from username . |
RequestToken |
stream(BaasHandler<BaasFile> handler) |
<R> RequestToken |
stream(DataStreamHandler<R> contentHandler,
BaasHandler<R> handler) |
<R> RequestToken |
stream(int flags,
DataStreamHandler<R> contentHandler,
BaasHandler<R> handler) |
<R> RequestToken |
stream(int sizeId,
int flags,
DataStreamHandler<R> contentHandler,
BaasHandler<R> handler) |
static <R> RequestToken |
stream(java.lang.String id,
DataStreamHandler<R> data,
BaasHandler<R> handler) |
static <R> RequestToken |
stream(java.lang.String id,
int flags,
DataStreamHandler<R> contentHandler,
BaasHandler<R> handler) |
BaasResult<BaasStream> |
streamImaeSync(int sizeId) |
RequestToken |
streamImage(int sizeIdx,
BaasHandler<BaasFile> handler) |
RequestToken |
streamImage(java.lang.String sizeSpec,
BaasHandler<BaasFile> handler) |
static <R> RequestToken |
streamImage(java.lang.String id,
int size,
DataStreamHandler<R> data,
BaasHandler<R> handler) |
static <R> RequestToken |
streamImage(java.lang.String id,
int size,
int flags,
DataStreamHandler<R> data,
BaasHandler<R> handler) |
BaasResult<BaasStream> |
streamImageSync(java.lang.String spec) |
static BaasResult<BaasStream> |
streamImageSync(java.lang.String id,
int sizeId) |
static BaasResult<BaasStream> |
streamImageSync(java.lang.String id,
java.lang.String spec) |
BaasResult<BaasStream> |
streamSync() |
RequestToken |
upload(BaasACL acl,
byte[] bytes,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(BaasACL acl,
byte[] bytes,
int flags,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(BaasACL acl,
java.io.File file,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(BaasACL acl,
java.io.File file,
int flags,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(BaasACL acl,
java.io.InputStream stream,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(BaasACL acl,
java.io.InputStream stream,
int flags,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(byte[] bytes,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(byte[] bytes,
int flags,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(java.io.File file,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(java.io.File file,
int flags,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(java.io.InputStream stream,
BaasHandler<BaasFile> handler) |
RequestToken |
upload(java.io.InputStream stream,
int flags,
BaasHandler<BaasFile> handler) |
BaasResult<BaasFile> |
uploadSync(BaasACL acl,
byte[] bytes) |
BaasResult<BaasFile> |
uploadSync(BaasACL acl,
java.io.File file) |
BaasResult<BaasFile> |
uploadSync(BaasACL acl,
java.io.InputStream stream) |
BaasResult<BaasFile> |
uploadSync(byte[] bytes) |
BaasResult<BaasFile> |
uploadSync(java.io.File file) |
BaasResult<BaasFile> |
uploadSync(java.io.InputStream stream) |
void |
writeToParcel(android.os.Parcel dest,
int flags) |
asDocument, asFile, grant, grantAll, isNew, revoke, revokeAll
public static final android.os.Parcelable.Creator<BaasFile> CREATOR
public BaasFile()
public BaasFile(JsonObject attachedData)
public void writeToParcel(android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable
public int describeContents()
describeContents
in interface android.os.Parcelable
public boolean isDirty()
isDirty
in class BaasObject
public static RequestToken fetchAll(BaasHandler<java.util.List<BaasFile>> handler)
public static RequestToken fetchAll(BaasQuery.Criteria filter, BaasHandler<java.util.List<BaasFile>> handler)
public static RequestToken fetchAll(BaasQuery.Criteria filter, int flags, BaasHandler<java.util.List<BaasFile>> handler)
public static BaasResult<java.util.List<BaasFile>> fetchAllSync()
public static BaasResult<java.util.List<BaasFile>> fetchAllSync(BaasQuery.Criteria filter)
public static RequestToken fetch(java.lang.String id, BaasHandler<BaasFile> handler)
public static RequestToken fetch(java.lang.String id, int flags, BaasHandler<BaasFile> handler)
public static BaasResult<BaasFile> fetchSync(java.lang.String id)
public static BaasResult<java.lang.Void> deleteSync(java.lang.String id)
public static RequestToken delete(java.lang.String id, BaasHandler<java.lang.Void> handler)
public static RequestToken delete(java.lang.String id, int flags, BaasHandler<java.lang.Void> handler)
public static RequestToken fetchStream(java.lang.String id, BaasHandler<BaasFile> handler)
public static BaasResult<BaasStream> streamImageSync(java.lang.String id, int sizeId)
public android.net.Uri getStreamUri()
public static BaasResult<BaasStream> streamImageSync(java.lang.String id, java.lang.String spec)
public static <R> RequestToken stream(java.lang.String id, DataStreamHandler<R> data, BaasHandler<R> handler)
public static <R> RequestToken streamImage(java.lang.String id, int size, DataStreamHandler<R> data, BaasHandler<R> handler)
public static <R> RequestToken stream(java.lang.String id, int flags, DataStreamHandler<R> contentHandler, BaasHandler<R> handler)
public static <R> RequestToken streamImage(java.lang.String id, int size, int flags, DataStreamHandler<R> data, BaasHandler<R> handler)
public JsonObject getAttachedData()
public final boolean isFile()
isFile
in class BaasObject
public final boolean isDocument()
isDocument
in class BaasObject
public JsonObject getMetadata()
public java.lang.String getAuthor()
BaasObject
getAuthor
in class BaasObject
public long getContentLength()
public java.lang.String getCreationDate()
BaasObject
getCreationDate
in class BaasObject
public java.lang.String getId()
BaasObject
getId
in class BaasObject
public long getVersion()
BaasObject
getVersion
in class BaasObject
public java.lang.String getContentType()
public byte[] getData()
public RequestToken delete(BaasHandler<java.lang.Void> handler)
public RequestToken delete(int flags, BaasHandler<java.lang.Void> handler)
public BaasResult<java.lang.Void> deleteSync()
public RequestToken grant(Grant grant, java.lang.String username, int flags, BaasHandler<java.lang.Void> handler)
BaasObject
grant
to this object to username
.
The outcome of the request is handed to the provided handler
.grant
in class BaasObject
grant
- a non null Grant
username
- a non null usernameflags
- RequestOptions
handler
- an handler that will receive the outcome of the request.RequestToken
to manage the asynchronous requestpublic RequestToken grantAll(Grant grant, java.lang.String role, int flags, BaasHandler<java.lang.Void> handler)
BaasObject
grant
to this object to users with role
.
The outcome of the request is handed to the provided handler
.grantAll
in class BaasObject
grant
- a non null Grant
role
- a non null usernameflags
- RequestOptions
handler
- an handler that will receive the outcome of the request.RequestToken
to manage the asynchronous requestpublic BaasResult<java.lang.Void> grantAllSync(Grant grant, java.lang.String role)
BaasObject
grant
to this object to all users in role
grantAllSync
in class BaasObject
grant
- a non null Grant
role
- a non null roleBaasResult
public BaasResult<java.lang.Void> grantSync(Grant grant, java.lang.String user)
BaasObject
grant
to this object to username
.grantSync
in class BaasObject
grant
- a non null Grant
user
- a non null usernameBaasResult
public RequestToken refresh(BaasHandler<BaasFile> handler)
public RequestToken refresh(int flags, BaasHandler<BaasFile> handler)
public BaasResult<BaasFile> refreshSync()
public RequestToken revoke(Grant grant, java.lang.String username, int flags, BaasHandler<java.lang.Void> handler)
BaasObject
grant
to this object to username
.
The outcome of the request is handed to the provided handler
.revoke
in class BaasObject
grant
- a non null Grant
username
- a non null usernameflags
- RequestOptions
handler
- an handler that will receive the outcome of the request.RequestToken
to manage the asynchronous requestpublic RequestToken revokeAll(Grant grant, java.lang.String role, int flags, BaasHandler<java.lang.Void> handler)
BaasObject
grant
to this object from users with role
.
The outcome of the request is handed to the provided handler
.revokeAll
in class BaasObject
grant
- a non null Grant
role
- a non null usernameflags
- RequestOptions
handler
- an handler that will receive the outcome of the request.RequestToken
to manage the asynchronous requestpublic BaasResult<java.lang.Void> revokeAllSync(Grant grant, java.lang.String role)
BaasObject
grant
to this object from all users in role
revokeAllSync
in class BaasObject
grant
- a non null Grant
role
- a non null roleBaasResult
public BaasResult<java.lang.Void> revokeSync(Grant grant, java.lang.String user)
BaasObject
grant
to this object from username
.revokeSync
in class BaasObject
grant
- a non null Grant
user
- a non null usernameBaasResult
public RequestToken extractedContent(int flags, BaasHandler<java.lang.String> handler)
public RequestToken extractedContent(BaasHandler<java.lang.String> handler)
public BaasResult<java.lang.String> extractedContentSync()
public RequestToken stream(BaasHandler<BaasFile> handler)
public RequestToken download(java.lang.String path, BaasHandler<android.util.Pair<BaasFile,java.lang.String>> handler)
public RequestToken streamImage(int sizeIdx, BaasHandler<BaasFile> handler)
public RequestToken streamImage(java.lang.String sizeSpec, BaasHandler<BaasFile> handler)
public <R> RequestToken stream(DataStreamHandler<R> contentHandler, BaasHandler<R> handler)
public <R> RequestToken stream(int flags, DataStreamHandler<R> contentHandler, BaasHandler<R> handler)
public <R> RequestToken stream(int sizeId, int flags, DataStreamHandler<R> contentHandler, BaasHandler<R> handler)
public BaasResult<BaasStream> streamSync()
public BaasResult<BaasStream> streamImageSync(java.lang.String spec)
public BaasResult<BaasStream> streamImaeSync(int sizeId)
public RequestToken upload(java.io.InputStream stream, BaasHandler<BaasFile> handler)
public RequestToken upload(java.io.File file, BaasHandler<BaasFile> handler)
public RequestToken upload(byte[] bytes, BaasHandler<BaasFile> handler)
public RequestToken upload(java.io.InputStream stream, int flags, BaasHandler<BaasFile> handler)
public RequestToken upload(BaasACL acl, java.io.InputStream stream, BaasHandler<BaasFile> handler)
public RequestToken upload(java.io.File file, int flags, BaasHandler<BaasFile> handler)
public RequestToken upload(BaasACL acl, java.io.File file, BaasHandler<BaasFile> handler)
public RequestToken upload(byte[] bytes, int flags, BaasHandler<BaasFile> handler)
public RequestToken upload(BaasACL acl, byte[] bytes, BaasHandler<BaasFile> handler)
public RequestToken upload(BaasACL acl, java.io.InputStream stream, int flags, BaasHandler<BaasFile> handler)
public RequestToken upload(BaasACL acl, java.io.File file, int flags, BaasHandler<BaasFile> handler)
public RequestToken upload(BaasACL acl, byte[] bytes, int flags, BaasHandler<BaasFile> handler)
public BaasResult<BaasFile> uploadSync(java.io.InputStream stream)
public BaasResult<BaasFile> uploadSync(BaasACL acl, java.io.InputStream stream)
public BaasResult<BaasFile> uploadSync(byte[] bytes)
public BaasResult<BaasFile> uploadSync(BaasACL acl, byte[] bytes)
public BaasResult<BaasFile> uploadSync(java.io.File file)
public BaasResult<BaasFile> uploadSync(BaasACL acl, java.io.File file)