Package cn.leancloud
Class LCFile
java.lang.Object
cn.leancloud.LCObject
cn.leancloud.LCFile
-
Nested Class Summary
Nested classes/interfaces inherited from class cn.leancloud.LCObject
LCObject.Hook -
Field Summary
FieldsFields inherited from class cn.leancloud.LCObject
acl, className, endpointClassName, KEY_ACL, KEY_CLASSNAME, KEY_CREATED_AT, KEY_IGNORE_HOOKS, KEY_OBJECT_ID, KEY_UPDATED_AT, logger, objectId, operations, serverData, totallyOverwrite, UUID_LEN -
Constructor Summary
ConstructorsModifierConstructorDescriptionLCFile()default constructor.constructor with name and data.constructor with name and local file.constructor with name and external url.constructor with name and external url.protected -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMetaData(String key, Object val) Add new meta data.voidCleanup meta data.voidclear folder path.booleanGet file attribute.Get file bucket.byte[]getData()Get data in blocking mode.io.reactivex.Observable<byte[]> Get data in async mode.Get data stream in blocking mode.io.reactivex.Observable<InputStream> Get data stream in async mode.getKey()Get file key.Get file meta data.getMetaData(String key) Get file meta data.Get file mime type.getName()Get file name.Get file provider.intgetSize()Get file size.getThumbnailUrl(boolean scaleToFit, int width, int height) Returns a thumbnail image url using QiNiu endpoints.getThumbnailUrl(boolean scaleToFit, int width, int height, int quality, String fmt) Returns a thumbnail image url using QiNiu endpoints.getUrl()Get file url.inthashCode()voidIncrement file attribute.voidIncrement file attribute.voidSet file attribute.voidRemove file attribute.removeMetaData(String key) Remove file meta data.voidsave()save to cloud.voidsave to cloudvoidSave eventually(not supported).voidsaveEventually(LCUser asAuthenticatedUser) Save eventually(not supported).io.reactivex.Observable<LCFile> save to cloud backend.io.reactivex.Observable<LCFile> saveInBackground(boolean keepFileName) save to cloud backend.voidsaveInBackground(boolean keepFileName, ProgressCallback progressCallback) save to cloud backend.voidsaveInBackground(ProgressCallback progressCallback) save to cloud backend.io.reactivex.Observable<LCFile> saveInBackground(LCUser asAuthenticatedUser, boolean keepFileName) save to cloud in background.voidsaveInBackground(LCUser asAuthenticatedUser, boolean keepFileName, ProgressCallback progressCallback) save to cloud in background.voidsetMetaData(Map<String, Object> metaData) Set file meta data.voidsetMimeType(String mimeType) Set file mime type.voidSet file name.voidsetPathPrefix(String path) set folder pathstatic voidsetUploadHeader(String key, String value) toMap()Get map data of current file.static LCFilewithAbsoluteLocalPath(String name, String absoluteLocalFilePath) Generate File instance with local path.static LCFileGenerate File instance with local file.static io.reactivex.Observable<LCFile> withObjectIdInBackground(String objectId) Get AVFile instance from objectId.Methods inherited from class cn.leancloud.LCObject
abortOperations, add, addAll, addAllUnique, addNewOperation, addUnique, bitAnd, bitOr, bitXor, cast, containsKey, createWithoutData, createWithoutData, decrement, decrement, delete, delete, deleteAll, deleteAll, deleteAllInBackground, deleteAllInBackground, deleteEventually, deleteEventually, deleteInBackground, deleteInBackground, disableAfterHook, disableBeforeHook, extractCascadingObjects, extractUnsavedFiles, fetch, fetch, fetch, fetchIfNeeded, fetchIfNeededInBackground, fetchIfNeededInBackground, fetchIfNeededInBackground, fetchInBackground, fetchInBackground, fetchInBackground, generateACLFromServerData, generateCascadingSaveObjects, generateChangedParam, getACL, getBoolean, getBytes, getClassName, getCreatedAt, getCreatedAtString, getDate, getDouble, getInt, getJSONArray, getJSONObject, getLCFile, getLCGeoPoint, getLCObject, getList, getLong, getNumber, getObjectId, getQuery, getRelation, getRequestMethod, getRequestRawEndpoint, getServerData, getString, getUnsavedFiles, getUpdatedAt, getUpdatedAtString, getUuid, has, hasCircleReference, ignoreHook, internalClassName, internalGet, internalId, internalPut, isDataAvailable, isFetchWhenSave, onDataSynchronized, onSaveFailure, onSaveSuccess, parseLCObject, refresh, refresh, refresh, refreshInBackground, refreshInBackground, refreshInBackground, refreshInBackground, registerSubclass, removeAll, removeOperationForKey, resetAll, resetByRawData, resetServerData, saveAll, saveAll, saveAllInBackground, saveAllInBackground, saveInBackground, saveInBackground, saveInBackground, setACL, setClassName, setFetchWhenSave, setObjectId, toJSONObject, toJSONString, toString, validFieldName, verifyInternalId
-
Field Details
-
CLASS_NAME
- See Also:
-
-
Constructor Details
-
LCFile
public LCFile()default constructor. -
LCFile
constructor with name and data.- Parameters:
name- file name.data- binary data.
-
LCFile
constructor with name and local file.- Parameters:
name- file name.localFile- local file.
-
LCFile
constructor with name and external url.- Parameters:
name- file name.url- external url.
-
LCFile
constructor with name and external url.- Parameters:
name- file nameurl- external url.metaData- additional attributes.
-
LCFile
-
-
Method Details
-
setUploadHeader
-
equals
-
hashCode
public int hashCode() -
withObjectIdInBackground
Get AVFile instance from objectId.- Parameters:
objectId- file objectId.- Returns:
- observable instance.
-
getName
Get file name.- Returns:
- file name.
-
setName
Set file name.- Parameters:
name- file name.
-
setPathPrefix
set folder path- Parameters:
path- folder path. null or empty string equals to clearPathPrefix.
-
clearPathPrefix
public void clearPathPrefix()clear folder path. -
getMetaData
Get file meta data.- Returns:
- meta data.
-
setMetaData
Set file meta data.- Parameters:
metaData- meta data.
-
addMetaData
Add new meta data.- Parameters:
key- meta key.val- meta value.
-
getMetaData
Get file meta data.- Parameters:
key- meta key.- Returns:
- meta value.
-
removeMetaData
Remove file meta data.- Parameters:
key- meta key.- Returns:
- old value.
-
clearMetaData
public void clearMetaData()Cleanup meta data. -
getSize
public int getSize()Get file size.- Returns:
- file size.
-
getMimeType
Get file mime type.- Returns:
- mime type.
-
setMimeType
Set file mime type.- Parameters:
mimeType- mime type.
-
getKey
Get file key.- Returns:
- file key.
-
getBucket
Get file bucket.- Returns:
- file bucket.
-
getUrl
Get file url.- Returns:
- file url.
-
getProvider
Get file provider.- Returns:
- file provider.
-
put
Set file attribute. -
get
Get file attribute. -
remove
Remove file attribute. -
increment
Increment file attribute. -
increment
Increment file attribute. -
getThumbnailUrl
Returns a thumbnail image url using QiNiu endpoints.- Parameters:
scaleToFit- scale param.width- width.height- height.- Returns:
- new url for thumbnail.
- See Also:
-
getThumbnailUrl
Returns a thumbnail image url using QiNiu endpoints.- Parameters:
scaleToFit- scale param.width- widthheight- heightquality- quality.fmt- format string.- Returns:
- new url for thumbnail.
-
toMap
Get map data of current file.- Returns:
- map data.
-
saveInBackground
save to cloud backend.- Parameters:
keepFileName- whether keep file name in url or not.progressCallback- progress callback.
-
saveInBackground
public void saveInBackground(LCUser asAuthenticatedUser, boolean keepFileName, ProgressCallback progressCallback) save to cloud in background.- Parameters:
asAuthenticatedUser- explicit user for request authentication.keepFileName- whether keep file name in url or not.progressCallback- progress callback. in general, this method should be invoked in lean engine.
-
saveInBackground
save to cloud backend.- Parameters:
progressCallback- progress callback.
-
saveInBackground
save to cloud backend.- Overrides:
saveInBackgroundin classLCObject- Returns:
- Observable object.
-
save
public void save()save to cloud. -
save
save to cloud -
saveInBackground
save to cloud backend.- Parameters:
keepFileName- whether keep file name in url or not.- Returns:
- Observable object.
-
saveEventually
Save eventually(not supported).- Overrides:
saveEventuallyin classLCObject- Throws:
LCException- exception happened. Because that file size is too big, cache the entire data will cost much disk capacity, so we don't support this method at present.
-
saveEventually
Save eventually(not supported).- Overrides:
saveEventuallyin classLCObject- Parameters:
asAuthenticatedUser- explicit user for request authentication.- Throws:
LCException- exception happened. Because that file size is too big, cache the entire data will cost much disk capacity, so we don't support this method at present.
-
saveInBackground
public io.reactivex.Observable<LCFile> saveInBackground(LCUser asAuthenticatedUser, boolean keepFileName) save to cloud in background.- Parameters:
asAuthenticatedUser- explicit user for request authentication.keepFileName- whether keep file name in url or not.- Returns:
- Observable object. in general, this method should be invoked in lean engine.
-
getData
public byte[] getData()Get data in blocking mode.- Returns:
- data bytes.
-
getDataInBackground
public io.reactivex.Observable<byte[]> getDataInBackground()Get data in async mode.- Returns:
- observable instance.
-
getDataStream
Get data stream in blocking mode.- Returns:
- data stream.
- Throws:
Exception- for file not found or io problem.
-
getDataStreamInBackground
Get data stream in async mode.- Returns:
- observable instance.
-
withAbsoluteLocalPath
public static LCFile withAbsoluteLocalPath(String name, String absoluteLocalFilePath) throws FileNotFoundException Generate File instance with local path.- Parameters:
name- file nameabsoluteLocalFilePath- local path.- Returns:
- file instance.
- Throws:
FileNotFoundException- file not found.
-
withFile
Generate File instance with local file.- Parameters:
name- file name.file- local file.- Returns:
- file instance.
- Throws:
FileNotFoundException- file not found.
-