public final class AVFile extends Object
AVFile is a local representation of a file that is saved to the AVOSCloud cloud.
The workflow is to construct a AVFile with data and optionally a filename. Then save it and set it as a field on a AVObject.
Example:
AVFile file = new AVFile("hello".getBytes());
file.save();
AVObject object = new AVObject("TestObject");
object.put("file", file);
object.save();
| Modifier | Constructor and Description |
|---|---|
|
AVFile() |
|
AVFile(byte[] data)
Deprecated.
|
|
AVFile(String name,
byte[] data)
Creates a new file from a byte array and a name.
|
protected |
AVFile(String name,
String url) |
|
AVFile(String name,
String url,
Map<String,Object> metaData)
创建一个基于网络文件的AVFile对象
|
| Modifier and Type | Method and Description |
|---|---|
Object |
addMetaData(String key,
Object val)
Added meta data to file.
|
void |
cancel()
Cancels the current network request and callbacks whether it's uploading or fetching data from
the server.
|
void |
clearMetaData()
Clear file metadata.
|
void |
delete() |
void |
deleteEventually() |
void |
deleteEventually(DeleteCallback callback) |
void |
deleteInBackground() |
void |
deleteInBackground(DeleteCallback callback) |
static AVFile |
fileFromMap(Map<String,Object> map) |
protected AVACL |
getACL()
获取AVFile的ACL
|
String |
getBucket() |
byte[] |
getData()
Deprecated.
|
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.
|
HashMap<String,Object> |
getMetaData()
Returns the file's metadata map.
|
Object |
getMetaData(String key)
Returns the metadata value by key.
|
static String |
getMimeType(String url) |
String |
getName()
The filename.
|
String |
getObjectId()
Returns the file object Id.
|
String |
getOriginalName() |
String |
getOwnerObjectId()
Returns the file's owner
|
int |
getSize()
Returns the file size in bytes.
|
String |
getThumbnailUrl(boolean scaleToFit,
int width,
int height)
Returns a thumbnail image url using QiNiu endpoints.
|
String |
getThumbnailUrl(boolean scaleToFit,
int width,
int height,
int quality,
String fmt)
返回缩略图URl 这个服务仅仅适用于保存在Qiniu的图片
|
Uploader |
getUploader(SaveCallback saveCallback,
ProgressCallback progressCallback) |
String |
getUrl()
This returns the url of the file.
|
boolean |
isDataAvailable()
Deprecated.
|
boolean |
isDirty()
Whether the file still needs to be saved.
|
static AVFile |
parseFileWithAbsoluteLocalPath(String name,
String absoluteLocalFilePath)
Deprecated.
Please use #
withAbsoluteLocalPath(String, String) |
static AVFile |
parseFileWithAVObject(AVObject obj)
Deprecated.
Please use #
withAVObject(AVObject) |
static AVFile |
parseFileWithFile(String name,
File file)
Deprecated.
Please use #
withFile(String, File) |
static AVFile |
parseFileWithObjectId(String objectId)
Deprecated.
Please use #
withObjectId(String) |
static void |
parseFileWithObjectIdInBackground(String objectId,
GetFileCallback<AVFile> cb)
Deprecated.
|
Object |
removeMetaData(String key)
Remove file meta data.
|
void |
save()
Saves the file to the AVOSCloud cloud synchronously.
|
void |
saveInBackground()
Saves the file to the AVOSCloud cloud in a background thread.
|
void |
saveInBackground(SaveCallback callback)
Saves the file to the AVOSCloud cloud in a background thread.
|
void |
saveInBackground(SaveCallback saveCallback,
ProgressCallback progressCallback)
Saves the file to the AVOSCloud cloud in a background thread.
|
void |
setACL(AVACL acl) |
void |
setBucket(String bucket) |
void |
setObjectId(String objectId)
Set the file objectId.
|
protected org.json.JSONObject |
toJSONObject() |
Map<String,Object> |
toMap() |
static AVFile |
withAbsoluteLocalPath(String name,
String absoluteLocalFilePath)
Creates a new file from local file path.
|
static AVFile |
withAVObject(AVObject obj)
Construct a AVFile from AVObject.
|
static AVFile |
withFile(String name,
File file)
Creates a new file from java.io.File object.
|
static AVFile |
withObjectId(String objectId)
Retrieve a AVFile object by object id from AVOSCloud.If the file is not found,it will throw
java.io.FileNotFoundException.
|
static void |
withObjectIdInBackground(String objectId,
GetFileCallback<AVFile> cb)
Retrieve a AVFile object by object id from AVOSCloud in background.If the file is not found,it
will call the callback with java.io.FileNotFoundException.
|
public AVFile()
@Deprecated public AVFile(byte[] data)
data - The file's data. 请注明文件名public AVFile(String name, String url, Map<String,Object> metaData)
name - 文件名url - 网络文件的urlmetaData - 网络文件的元信息,可以为空public AVFile(String name, byte[] data)
name - The file's name, ideally with extension.data - The file's datapublic String getObjectId()
public void setObjectId(String objectId)
objectId - file object id.@Deprecated public static void parseFileWithObjectIdInBackground(String objectId, GetFileCallback<AVFile> cb)
withObjectIdInBackground(String, GetFileCallback)objectId - The file object id.cb - The GetFileCallback instance.public static void withObjectIdInBackground(String objectId, GetFileCallback<AVFile> cb)
objectId - The file object id.cb - The GetFileCallback instance.@Deprecated public static AVFile parseFileWithObjectId(String objectId) throws AVException, FileNotFoundException
withObjectId(String)objectId - objectId in _File tableAVException - exception if _File table object failed to transfer to AVFile objectFileNotFoundException - exception if objectId is not invalidpublic static AVFile withObjectId(String objectId) throws AVException, FileNotFoundException
objectId - objectId in _File tableAVException - excpetion if _File table object failed to transfer to AVFile objectFileNotFoundException - exception if objectId is not invalid@Deprecated public static AVFile parseFileWithAVObject(AVObject obj)
withAVObject(AVObject)obj - The parse object.public static AVFile withAVObject(AVObject obj)
obj - The parse object.@Deprecated public static AVFile parseFileWithAbsoluteLocalPath(String name, String absoluteLocalFilePath) throws Exception
withAbsoluteLocalPath(String, String)name - The file's name, ideally with extension.absoluteLocalFilePath - The file's absolute path.Exception - exception if file not found on pathpublic static AVFile withAbsoluteLocalPath(String name, String absoluteLocalFilePath) throws FileNotFoundException
name - The file's name, ideally with extension.absoluteLocalFilePath - The file's absolute path.FileNotFoundException - exception if file not found@Deprecated public static AVFile parseFileWithFile(String name, File file) throws FileNotFoundException
withFile(String, File)name - The file's name, ideally with extension.file - The file object.FileNotFoundExceptionpublic static AVFile withFile(String name, File file) throws FileNotFoundException
name - The file's name, ideally with extension.file - The file object.FileNotFoundException - exception if file not foundpublic HashMap<String,Object> getMetaData()
public Object addMetaData(String key, Object val)
key - The meta data's key.val - The meta data's value.public Object getMetaData(String key)
key - The metadata keypublic int getSize()
public String getOwnerObjectId()
public Object removeMetaData(String key)
key - The meta data's keypublic void clearMetaData()
public String getName()
public String getOriginalName()
public boolean isDirty()
@Deprecated public boolean isDataAvailable()
public String getUrl()
public String getThumbnailUrl(boolean scaleToFit, int width, int height)
scaleToFit - Whether to scale the imagewidth - The thumbnail image's widthheight - The thumbnail image'heightgetThumbnailUrl(boolean, int, int, int, String)public String getThumbnailUrl(boolean scaleToFit, int width, int height, int quality, String fmt)
scaleToFit - Whether to scale the imagewidth - The thumbnail image's widthheight - The thumbnail image'heightquality - The thumbnail image quality in 1 - 100.fmt - The thumbnail image format such as 'jpg','gif','png','tif' etc.public void save()
throws AVException
AVException - exception during savepublic 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 void saveInBackground()
@Deprecated public byte[] getData() throws AVException
AVException - exception during file data retrievepublic 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()
public void delete()
throws AVException
AVException - exception during deleteAVObject.delete()public void deleteEventually()
AVObject.deleteEventually()public void deleteEventually(DeleteCallback callback)
callback - callbackAVObject.deleteEventually(DeleteCallback callback)public void deleteInBackground()
AVObject.deleteInBackground()public void deleteInBackground(DeleteCallback callback)
callback - callback.done(e) is called when the delete completesAVObject.deleteInBackground(DeleteCallback callback)public Uploader getUploader(SaveCallback saveCallback, ProgressCallback progressCallback)
public String getBucket()
public void setBucket(String bucket)
protected AVACL getACL()
public void setACL(AVACL acl)
protected org.json.JSONObject toJSONObject()
Copyright © 2017. All rights reserved.