程序包 cn.leancloud

类 LCFile


  • public final class LCFile
    extends LCObject
    • 字段详细资料

      • CLASS_NAME

        public static final java.lang.String CLASS_NAME
        另请参阅:
        常量字段值
    • 构造器详细资料

      • LCFile

        public LCFile()
        default constructor.
      • LCFile

        public LCFile​(java.lang.String name,
                      byte[] data)
        constructor with name and data.
        参数:
        name - file name.
        data - binary data.
      • LCFile

        public LCFile​(java.lang.String name,
                      java.io.File localFile)
        constructor with name and local file.
        参数:
        name - file name.
        localFile - local file.
      • LCFile

        public LCFile​(java.lang.String name,
                      java.lang.String url)
        constructor with name and external url.
        参数:
        name - file name.
        url - external url.
      • LCFile

        public LCFile​(java.lang.String name,
                      java.lang.String url,
                      java.util.Map<java.lang.String,​java.lang.Object> metaData)
        constructor with name and external url.
        参数:
        name - file name
        url - external url.
        metaData - additional attributes.
      • LCFile

        protected LCFile​(java.lang.String name,
                         java.lang.String url,
                         java.util.Map<java.lang.String,​java.lang.Object> metaData,
                         boolean external)
    • 方法详细资料

      • setUploadHeader

        public static void setUploadHeader​(java.lang.String key,
                                           java.lang.String value)
      • equals

        public boolean equals​(java.lang.Object o)
        覆盖:
        equals 在类中 LCObject
      • withObjectIdInBackground

        public static io.reactivex.Observable<LCFile> withObjectIdInBackground​(java.lang.String objectId)
        Get AVFile instance from objectId.
        参数:
        objectId - file objectId.
        返回:
        observable instance.
      • getName

        public java.lang.String getName()
        Get file name.
        返回:
        file name.
      • setName

        public void setName​(java.lang.String name)
        Set file name.
        参数:
        name - file name.
      • setPathPrefix

        public void setPathPrefix​(java.lang.String path)
        set folder path
        参数:
        path - folder path. null or empty string equals to clearPathPrefix.
      • clearPathPrefix

        public void clearPathPrefix()
        clear folder path.
      • getMetaData

        public java.util.Map<java.lang.String,​java.lang.Object> getMetaData()
        Get file meta data.
        返回:
        meta data.
      • setMetaData

        public void setMetaData​(java.util.Map<java.lang.String,​java.lang.Object> metaData)
        Set file meta data.
        参数:
        metaData - meta data.
      • addMetaData

        public void addMetaData​(java.lang.String key,
                                java.lang.Object val)
        Add new meta data.
        参数:
        key - meta key.
        val - meta value.
      • getMetaData

        public java.lang.Object getMetaData​(java.lang.String key)
        Get file meta data.
        参数:
        key - meta key.
        返回:
        meta value.
      • removeMetaData

        public java.lang.Object removeMetaData​(java.lang.String key)
        Remove file meta data.
        参数:
        key - meta key.
        返回:
        old value.
      • clearMetaData

        public void clearMetaData()
        Cleanup meta data.
      • getSize

        public int getSize()
        Get file size.
        返回:
        file size.
      • getMimeType

        public java.lang.String getMimeType()
        Get file mime type.
        返回:
        mime type.
      • setMimeType

        public void setMimeType​(java.lang.String mimeType)
        Set file mime type.
        参数:
        mimeType - mime type.
      • getKey

        public java.lang.String getKey()
        Get file key.
        返回:
        file key.
      • getBucket

        public java.lang.String getBucket()
        Get file bucket.
        返回:
        file bucket.
      • getUrl

        public java.lang.String getUrl()
        Get file url.
        返回:
        file url.
      • getProvider

        public java.lang.String getProvider()
        Get file provider.
        返回:
        file provider.
      • put

        public void put​(java.lang.String key,
                        java.lang.Object value)
        Set file attribute.
        覆盖:
        put 在类中 LCObject
        参数:
        key - attribute key.
        value - attribute value. notice: UnsupportedOperationException
      • get

        public java.lang.Object get​(java.lang.String key)
        Get file attribute.
        覆盖:
        get 在类中 LCObject
        参数:
        key - attribute key.
        返回:
        attribute value. notice: UnsupportedOperationException
      • remove

        public void remove​(java.lang.String key)
        Remove file attribute.
        覆盖:
        remove 在类中 LCObject
        参数:
        key - attribute key. notice: UnsupportedOperationException
      • increment

        public void increment​(java.lang.String key)
        Increment file attribute.
        覆盖:
        increment 在类中 LCObject
        参数:
        key - attribute key. notice: UnsupportedOperationException
      • increment

        public void increment​(java.lang.String key,
                              java.lang.Number value)
        Increment file attribute.
        覆盖:
        increment 在类中 LCObject
        参数:
        key - attribute key.
        value - step value. notice: UnsupportedOperationException
      • getThumbnailUrl

        public java.lang.String getThumbnailUrl​(boolean scaleToFit,
                                                int width,
                                                int height)
        Returns a thumbnail image url using QiNiu endpoints.
        参数:
        scaleToFit - scale param.
        width - width.
        height - height.
        返回:
        new url for thumbnail.
        另请参阅:
        getThumbnailUrl(boolean, int, int, int, String)
      • getThumbnailUrl

        public java.lang.String getThumbnailUrl​(boolean scaleToFit,
                                                int width,
                                                int height,
                                                int quality,
                                                java.lang.String fmt)
        Returns a thumbnail image url using QiNiu endpoints.
        参数:
        scaleToFit - scale param.
        width - width
        height - height
        quality - quality.
        fmt - format string.
        返回:
        new url for thumbnail.
      • toMap

        public java.util.Map<java.lang.String,​java.lang.Object> toMap()
        Get map data of current file.
        返回:
        map data.
      • saveInBackground

        public void saveInBackground​(boolean keepFileName,
                                     ProgressCallback progressCallback)
        save to cloud backend.
        参数:
        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.
        参数:
        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

        public void saveInBackground​(ProgressCallback progressCallback)
        save to cloud backend.
        参数:
        progressCallback - progress callback.
      • saveInBackground

        public io.reactivex.Observable<LCFile> saveInBackground()
        save to cloud backend.
        覆盖:
        saveInBackground 在类中 LCObject
        返回:
        Observable object.
      • save

        public void save()
        save to cloud.
        覆盖:
        save 在类中 LCObject
      • save

        public void save​(LCUser asAuthenticatedUser)
        save to cloud
        覆盖:
        save 在类中 LCObject
        参数:
        asAuthenticatedUser - explicit user for request authentication.
      • saveInBackground

        public io.reactivex.Observable<LCFile> saveInBackground​(boolean keepFileName)
        save to cloud backend.
        参数:
        keepFileName - whether keep file name in url or not.
        返回:
        Observable object.
      • saveEventually

        public void saveEventually()
                            throws LCException
        Save eventually(not supported).
        覆盖:
        saveEventually 在类中 LCObject
        抛出:
        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

        public void saveEventually​(LCUser asAuthenticatedUser)
                            throws LCException
        Save eventually(not supported).
        覆盖:
        saveEventually 在类中 LCObject
        参数:
        asAuthenticatedUser - explicit user for request authentication.
        抛出:
        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.
        参数:
        asAuthenticatedUser - explicit user for request authentication.
        keepFileName - whether keep file name in url or not.
        返回:
        Observable object. in general, this method should be invoked in lean engine.
      • getData

        public byte[] getData()
        Get data in blocking mode.
        返回:
        data bytes.
      • getDataInBackground

        public io.reactivex.Observable<byte[]> getDataInBackground()
        Get data in async mode.
        返回:
        observable instance.
      • getDataStream

        public java.io.InputStream getDataStream()
                                          throws java.lang.Exception
        Get data stream in blocking mode.
        返回:
        data stream.
        抛出:
        java.lang.Exception - for file not found or io problem.
      • getDataStreamInBackground

        public io.reactivex.Observable<java.io.InputStream> getDataStreamInBackground()
        Get data stream in async mode.
        返回:
        observable instance.
      • withAbsoluteLocalPath

        public static LCFile withAbsoluteLocalPath​(java.lang.String name,
                                                   java.lang.String absoluteLocalFilePath)
                                            throws java.io.FileNotFoundException
        Generate File instance with local path.
        参数:
        name - file name
        absoluteLocalFilePath - local path.
        返回:
        file instance.
        抛出:
        java.io.FileNotFoundException - file not found.
      • withFile

        public static LCFile withFile​(java.lang.String name,
                                      java.io.File file)
                               throws java.io.FileNotFoundException
        Generate File instance with local file.
        参数:
        name - file name.
        file - local file.
        返回:
        file instance.
        抛出:
        java.io.FileNotFoundException - file not found.