类 ObjectMetadata


  • public class ObjectMetadata
    extends java.lang.Object
    Represents the object metadata that is stored with Qcloud COS. This includes custom user-supplied metadata, as well as the standard HTTP headers that Qcloud COS sends and receives (Content-Length, ETag, Content-MD5, etc.).
    • 构造器概要

      构造器 
      构造器 说明
      ObjectMetadata()  
      ObjectMetadata​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers)  
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void addUserMetadata​(java.lang.String key, java.lang.String value)
      Adds the key value pair of custom user-metadata for the associated object.
      ObjectMetadata clone()  
      java.lang.String getCacheControl()
      Gets the optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain.
      java.lang.String getContentDisposition()
      Gets the optional Content-Disposition HTTP header, which specifies presentation information for the object such as the recommended filename for the object to be saved as.
      java.lang.String getContentEncoding()
      Gets the optional Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field.
      java.lang.String getContentLanguage()
      Gets the Content-Language HTTP header, which describes the natural language(s) of the intended audience for the enclosed entity.
      long getContentLength()
      Gets the Content-Length HTTP header indicating the size of the associated object in bytes.
      java.lang.String getContentMD5()
      Gets the base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864.
      java.lang.String getContentType()
      Gets the Content-Type HTTP header, which indicates the type of content stored in the associated object.
      java.lang.String getCrc64Ecma()  
      java.lang.String getETag()
      Gets the hex encoded 128-bit MD5 digest of the associated object according to RFC 1864.
      java.util.Date getExpirationTime()
      Returns the time this object will expire and be completely removed from COS.
      java.util.Date getHttpExpiresDate()
      Returns the date when the object is no longer cacheable.
      long getInstanceLength()
      Returns the physical length of the entire object stored in COS.
      java.util.Date getLastModified()
      Gets the value of the Last-Modified header, indicating the date and time at which Qcloud COS last recorded a modification to the associated object.
      java.lang.Boolean getOngoingRestore()
      Returns the boolean value which indicates whether there is ongoing restore request.
      java.util.Map<java.lang.String,​java.lang.Object> getRawMetadata()
      For internal use only.
      java.lang.Object getRawMetadataValue​(java.lang.String key)
      For internal use only.
      java.util.Date getRestoreExpirationTime()
      Returns the time at which an object that has been temporarily restored from CAS will expire, and will need to be restored again in order to be accessed.
      java.lang.String getServerSideEncryption()
      Returns the server-side encryption algorithm for the object, or null if none was used.
      java.lang.String getSSEAlgorithm()  
      java.lang.String getSSECOSKmsKeyId()
      Returns the Key Management System key id used for Server Side Encryption of the COS object.
      java.lang.String getSSECustomerAlgorithm()  
      java.lang.String getSSECustomerKeyMd5()  
      java.lang.String getStorageClass()  
      java.util.Map<java.lang.String,​java.lang.String> getUserMetadata()
      Gets the custom user-metadata for the associated object.
      java.lang.String getUserMetaDataOf​(java.lang.String key)
      Returns the value of the specified user meta datum.
      java.lang.String getVersionId()
      Gets the version ID of the associated Qcloud COS object if available.
      boolean isDeleteMarker()  
      void setCacheControl​(java.lang.String cacheControl)
      Sets the optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain.
      void setContentDisposition​(java.lang.String disposition)
      Sets the optional Content-Disposition HTTP header, which specifies presentational information such as the recommended filename for the object to be saved as.
      void setContentEncoding​(java.lang.String encoding)
      Sets the optional Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field.
      void setContentLanguage​(java.lang.String contentLanguage)
      Sets the Content-Language HTTP header which describes the natural language(s) of the intended audience for the enclosed entity.
      void setContentLength​(long contentLength)
      Sets the Content-Length HTTP header indicating the size of the associated object in bytes.
      void setContentMD5​(java.lang.String md5Base64)
      Sets the base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864.
      void setContentType​(java.lang.String contentType)
      Sets the Content-Type HTTP header indicating the type of content stored in the associated object.
      void setDeleteMarker​(boolean isDeleteMarker)  
      void setExpirationTime​(java.util.Date expirationTime)
      For internal use only.
      void setHeader​(java.lang.String key, java.lang.Object value)
      For internal use only.
      void setHttpExpiresDate​(java.util.Date httpExpiresDate)
      Set the date when the object is no longer cacheable.
      void setLastModified​(java.util.Date lastModified)
      For internal use only.
      void setOngoingRestore​(boolean ongoingRestore)
      For internal use only.
      void setRestoreExpirationTime​(java.util.Date restoreExpirationTime)
      only used to set the value in the object after receiving the value in a response from COS.
      void setSecurityToken​(java.lang.String securityToken)
      Sets the security token for the object.
      void setServerSideEncryption​(java.lang.String serverSideEncryption)
      Sets the server-side encryption algorithm for the object.
      void setSSEAlgorithm​(java.lang.String algorithm)  
      void setSSECustomerAlgorithm​(java.lang.String algorithm)  
      void setSSECustomerKeyMd5​(java.lang.String md5Digest)  
      void setUserMetadata​(java.util.Map<java.lang.String,​java.lang.String> userMetadata)
      Sets the custom user-metadata for the associated object.
      • 从类继承的方法 java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • ObjectMetadata

        public ObjectMetadata()
      • ObjectMetadata

        public ObjectMetadata​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers)
    • 方法详细资料

      • getUserMetadata

        public java.util.Map<java.lang.String,​java.lang.String> getUserMetadata()

        Gets the custom user-metadata for the associated object.

        Qcloud COS can store additional metadata on objects by internally representing it as HTTP headers prefixed with "x-cos-meta-". Use user-metadata to store arbitrary metadata alongside their data in Qcloud COS. When setting user metadata, callers should not include the internal "x-cos-meta-" prefix; this library will handle that for them. Likewise, when callers retrieve custom user-metadata, they will not see the "x-cos-meta-" header prefix.

        User-metadata keys are case insensitive and will be returned as lowercase strings, even if they were originally specified with uppercase strings.

        Note that user-metadata for an object is limited by the HTTP request header limit. All HTTP headers included in a request (including user metadata headers and other standard HTTP headers) must be less than 8KB.

        返回:
        The custom user metadata for the associated object.
        另请参阅:
        setUserMetadata(Map), addUserMetadata(String, String)
      • setUserMetadata

        public void setUserMetadata​(java.util.Map<java.lang.String,​java.lang.String> userMetadata)

        Sets the custom user-metadata for the associated object.

        Qcloud COS can store additional metadata on objects by internally representing it as HTTP headers prefixed with "x-cos-meta-". Use user-metadata to store arbitrary metadata alongside their data in Qcloud COS. When setting user metadata, callers should not include the internal "x-cos-meta-" prefix; this library will handle that for them. Likewise, when callers retrieve custom user-metadata, they will not see the "x-cos-meta-" header prefix.

        User-metadata keys are case insensitive and will be returned as lowercase strings, even if they were originally specified with uppercase strings.

        Note that user-metadata for an object is limited by the HTTP request header limit. All HTTP headers included in a request (including user metadata headers and other standard HTTP headers) must be less than 8KB.

        参数:
        userMetadata - The custom user-metadata for the associated object. Note that the key should not include the internal COS HTTP header prefix.
        另请参阅:
        getUserMetadata(), addUserMetadata(String, String)
      • setHeader

        public void setHeader​(java.lang.String key,
                              java.lang.Object value)
        For internal use only. Sets a specific metadata header value. Not intended to be called by external code.
        参数:
        key - The name of the header being set.
        value - The value for the header.
      • addUserMetadata

        public void addUserMetadata​(java.lang.String key,
                                    java.lang.String value)

        Adds the key value pair of custom user-metadata for the associated object. If the entry in the custom user-metadata map already contains the specified key, it will be replaced with these new contents.

        Qcloud COS can store additional metadata on objects by internally representing it as HTTP headers prefixed with "x-cos-meta-". Use user-metadata to store arbitrary metadata alongside their data in Qcloud COS. When setting user metadata, callers should not include the internal "x-cos-meta-" prefix; this library will handle that for them. Likewise, when callers retrieve custom user-metadata, they will not see the "x-cos-meta-" header prefix.

        Note that user-metadata for an object is limited by the HTTP request header limit. All HTTP headers included in a request (including user metadata headers and other standard HTTP headers) must be less than 8KB.

        参数:
        key - The key for the custom user metadata entry. Note that the key should not include the internal COS HTTP header prefix.
        value - The value for the custom user-metadata entry.
        另请参阅:
        setUserMetadata(Map), getUserMetadata()
      • getRawMetadata

        public java.util.Map<java.lang.String,​java.lang.Object> getRawMetadata()
        For internal use only. Gets a map of the raw metadata/headers for the associated object.
        返回:
        A map of the raw metadata/headers for the associated object.
      • getRawMetadataValue

        public java.lang.Object getRawMetadataValue​(java.lang.String key)
        For internal use only. Returns the raw value of the metadata/headers for the specified key.
      • getLastModified

        public java.util.Date getLastModified()
        Gets the value of the Last-Modified header, indicating the date and time at which Qcloud COS last recorded a modification to the associated object.
        返回:
        The date and time at which Qcloud COS last recorded a modification to the associated object. Returns null if the Last-Modified header hasn't been set.
      • setLastModified

        public void setLastModified​(java.util.Date lastModified)
        For internal use only. Sets the Last-Modified header value indicating the date and time at which Qcloud COS last recorded a modification to the associated object.
        参数:
        lastModified - The date and time at which Qcloud COS last recorded a modification to the associated object.
      • getContentLength

        public long getContentLength()

        Gets the Content-Length HTTP header indicating the size of the associated object in bytes.

        This field is required when uploading objects to COS, but the COS Java client will automatically set it when working directly with files. When uploading directly from a stream, set this field if possible. Otherwise the client must buffer the entire stream in order to calculate the content length before sending the data to Qcloud COS.

        For more information on the Content-Length HTTP header, see http://www.w3.org/ Protocols/rfc2616/rfc2616-sec14.html#sec14.13

        返回:
        The Content-Length HTTP header indicating the size of the associated object in bytes. Returns null if it hasn't been set yet.
        另请参阅:
        setContentLength(long)
      • getInstanceLength

        public long getInstanceLength()
        Returns the physical length of the entire object stored in COS. This is useful during, for example, a range get operation.
      • setContentLength

        public void setContentLength​(long contentLength)

        Sets the Content-Length HTTP header indicating the size of the associated object in bytes.

        This field is required when uploading objects to COS, but the COS Java client will automatically set it when working directly with files. When uploading directly from a stream, set this field if possible. Otherwise the client must buffer the entire stream in order to calculate the content length before sending the data to Qcloud COS.

        For more information on the Content-Length HTTP header, see http://www.w3.org/ Protocols/rfc2616/rfc2616-sec14.html#sec14.13

        参数:
        contentLength - The Content-Length HTTP header indicating the size of the associated object in bytes.
        另请参阅:
        getContentLength()
      • getContentType

        public java.lang.String getContentType()

        Gets the Content-Type HTTP header, which indicates the type of content stored in the associated object. The value of this header is a standard MIME type.

        When uploading files, the COS Java client will attempt to determine the correct content type if one hasn't been set yet. Users are responsible for ensuring a suitable content type is set when uploading streams. If no content type is provided and cannot be determined by the filename, the default content type, "application/octet-stream", will be used.

        For more information on the Content-Type header, see http://www.w3.org/ Protocols/rfc2616/rfc2616-sec14.html#sec14.17

        返回:
        The HTTP Content-Type header, indicating the type of content stored in the associated object. Returns null if it hasn't been set.
        另请参阅:
        setContentType(String)
      • setContentType

        public void setContentType​(java.lang.String contentType)

        Sets the Content-Type HTTP header indicating the type of content stored in the associated object. The value of this header is a standard MIME type.

        When uploading files, the COS Java client will attempt to determine the correct content type if one hasn't been set yet. Users are responsible for ensuring a suitable content type is set when uploading streams. If no content type is provided and cannot be determined by the filename, the default content type "application/octet-stream" will be used.

        For more information on the Content-Type header, see http://www.w3.org/ Protocols/rfc2616/rfc2616-sec14.html#sec14.17

        参数:
        contentType - The HTTP Content-Type header indicating the type of content stored in the associated COS object.
        另请参阅:
        getContentType()
      • getContentLanguage

        public java.lang.String getContentLanguage()

        Gets the Content-Language HTTP header, which describes the natural language(s) of the intended audience for the enclosed entity.

      • setContentLanguage

        public void setContentLanguage​(java.lang.String contentLanguage)

        Sets the Content-Language HTTP header which describes the natural language(s) of the intended audience for the enclosed entity.

      • getContentEncoding

        public java.lang.String getContentEncoding()

        Gets the optional Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field.

        For more information on how the Content-Encoding HTTP header works, see http://www.w3.org/ Protocols/rfc2616/rfc2616-sec14.html#sec14.11

        返回:
        The HTTP Content-Encoding header. Returns null if it hasn't been set.
        另请参阅:
        setContentType(String)
      • getCacheControl

        public java.lang.String getCacheControl()

        Gets the optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain.

        For more information on how the Cache-Control HTTP header affects HTTP requests and responses, see http://www.w3.org/ Protocols/rfc2616/rfc2616-sec14.html#sec14.9

        返回:
        The HTTP Cache-Control header as defined in RFC 2616. Returns null if it hasn't been set.
        另请参阅:
        setCacheControl(String)
      • setCacheControl

        public void setCacheControl​(java.lang.String cacheControl)

        Sets the optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain.

        For more information on how the Cache-Control HTTP header affects HTTP requests and responses see http://www.w3.org/ Protocols/rfc2616/rfc2616-sec14.html#sec14.9

        参数:
        cacheControl - The HTTP Cache-Control header as defined in RFC 2616.
        另请参阅:
        getCacheControl()
      • setContentMD5

        public void setContentMD5​(java.lang.String md5Base64)

        Sets the base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864. This data is used as a message integrity check to verify that the data received by Qcloud COS is the same data that the caller sent. If set to null,then the MD5 digest is removed from the metadata.

        This field represents the base64 encoded 128-bit MD5 digest digest of an object's content as calculated on the caller's side. The ETag metadata field represents the hex encoded 128-bit MD5 digest as computed by Qcloud COS.

        The COS Java client will attempt to calculate this field automatically when uploading files to Qcloud COS.

        参数:
        md5Base64 - The base64 encoded MD5 hash of the content for the object associated with this metadata.
        另请参阅:
        getContentMD5()
      • getContentMD5

        public java.lang.String getContentMD5()

        Gets the base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864. This data is used as a message integrity check to verify that the data received by Qcloud COS is the same data that the caller sent.

        This field represents the base64 encoded 128-bit MD5 digest digest of an object's content as calculated on the caller's side. The ETag metadata field represents the hex encoded 128-bit MD5 digest as computed by Qcloud COS.

        The COS Java client will attempt to calculate this field automatically when uploading files to Qcloud COS.

        返回:
        The base64 encoded MD5 hash of the content for the associated object. Returns null if the MD5 hash of the content hasn't been set.
        另请参阅:
        setContentMD5(String)
      • setContentDisposition

        public void setContentDisposition​(java.lang.String disposition)

        Sets the optional Content-Disposition HTTP header, which specifies presentational information such as the recommended filename for the object to be saved as.

        For more information on how the Content-Disposition header affects HTTP client behavior, see http://www.w3.org /Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1

        参数:
        disposition - The value for the Content-Disposition header.
        另请参阅:
        getContentDisposition()
      • getETag

        public java.lang.String getETag()
        Gets the hex encoded 128-bit MD5 digest of the associated object according to RFC 1864. This data is used as an integrity check to verify that the data received by the caller is the same data that was sent by Qcloud COS.

        This field represents the hex encoded 128-bit MD5 digest of an object's content as calculated by Qcloud COS. The ContentMD5 field represents the base64 encoded 128-bit MD5 digest as calculated on the caller's side.

        返回:
        The hex encoded MD5 hash of the content for the associated object as calculated by Qcloud COS. Returns null if it hasn't been set yet.
      • getVersionId

        public java.lang.String getVersionId()
        Gets the version ID of the associated Qcloud COS object if available. Version IDs are only assigned to objects when an object is uploaded to an Qcloud COS bucket that has object versioning enabled.
        返回:
        The version ID of the associated Qcloud COS object if available.
      • getServerSideEncryption

        public java.lang.String getServerSideEncryption()
        Returns the server-side encryption algorithm for the object, or null if none was used.
      • setServerSideEncryption

        public void setServerSideEncryption​(java.lang.String serverSideEncryption)
        Sets the server-side encryption algorithm for the object.
        参数:
        serverSideEncryption - The server-side encryption algorithm for the object.
      • setSecurityToken

        public void setSecurityToken​(java.lang.String securityToken)
        Sets the security token for the object.
        参数:
        securityToken - The security token for the object.
      • getExpirationTime

        public java.util.Date getExpirationTime()
        Returns the time this object will expire and be completely removed from COS. Returns null if this object will never expire.
      • setExpirationTime

        public void setExpirationTime​(java.util.Date expirationTime)
        For internal use only. This will *not* set the object's expiration time, and is only used to set the value in the object after receiving the value in a response from COS.
        参数:
        expirationTime - The expiration time for the object.
      • setHttpExpiresDate

        public void setHttpExpiresDate​(java.util.Date httpExpiresDate)
        Set the date when the object is no longer cacheable.
      • getHttpExpiresDate

        public java.util.Date getHttpExpiresDate()
        Returns the date when the object is no longer cacheable.
      • getRestoreExpirationTime

        public java.util.Date getRestoreExpirationTime()
        Returns the time at which an object that has been temporarily restored from CAS will expire, and will need to be restored again in order to be accessed. Returns null if this is not a temporary copy of an object restored from CAS.
      • setRestoreExpirationTime

        public void setRestoreExpirationTime​(java.util.Date restoreExpirationTime)
        only used to set the value in the object after receiving the value in a response from COS.
        参数:
        restoreExpirationTime - The new restore expiration time for the object.
      • setOngoingRestore

        public void setOngoingRestore​(boolean ongoingRestore)
        For internal use only. Sets the boolean value which indicates whether there is ongoing restore request. Not intended to be called by external code.
      • getOngoingRestore

        public java.lang.Boolean getOngoingRestore()
        Returns the boolean value which indicates whether there is ongoing restore request.
      • isDeleteMarker

        public boolean isDeleteMarker()
      • setDeleteMarker

        public void setDeleteMarker​(boolean isDeleteMarker)
      • getUserMetaDataOf

        public java.lang.String getUserMetaDataOf​(java.lang.String key)
        Returns the value of the specified user meta datum.
      • clone

        public ObjectMetadata clone()
        覆盖:
        clone 在类中 java.lang.Object
      • getSSEAlgorithm

        public java.lang.String getSSEAlgorithm()
      • setSSEAlgorithm

        public void setSSEAlgorithm​(java.lang.String algorithm)
      • getSSECustomerAlgorithm

        public java.lang.String getSSECustomerAlgorithm()
      • setSSECustomerAlgorithm

        public void setSSECustomerAlgorithm​(java.lang.String algorithm)
      • getSSECustomerKeyMd5

        public java.lang.String getSSECustomerKeyMd5()
      • setSSECustomerKeyMd5

        public void setSSECustomerKeyMd5​(java.lang.String md5Digest)
      • getStorageClass

        public java.lang.String getStorageClass()
        返回:
        The storage class of the object. Returns null if the object is in STANDARD storage.
      • getSSECOSKmsKeyId

        public java.lang.String getSSECOSKmsKeyId()
        Returns the Key Management System key id used for Server Side Encryption of the COS object.
      • getCrc64Ecma

        public java.lang.String getCrc64Ecma()