public class COSObject extends Object implements Closeable, Serializable
| Constructor and Description |
|---|
COSObject() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Releases any underlying system resources.
|
String |
getBucketName()
Gets the name of the bucket in which this object is contained.
|
String |
getKey()
Gets the key under which this object is stored.
|
COSObjectInputStream |
getObjectContent()
Gets the input stream containing the contents of this object.
|
ObjectMetadata |
getObjectMetadata()
Gets the metadata stored by Qcloud COS for this object.
|
void |
setBucketName(String bucketName)
Sets the name of the bucket in which this object is contained.
|
void |
setKey(String key)
Sets the key under which this object is stored.
|
void |
setObjectContent(COSObjectInputStream objectContent)
Sets the input stream containing this object's contents.
|
void |
setObjectContent(InputStream objectContent)
Sets the input stream containing this object's contents.
|
void |
setObjectMetadata(ObjectMetadata metadata)
Sets the object metadata for this object.
|
String |
toString() |
public ObjectMetadata getObjectMetadata()
ObjectMetadata object
includes any custom user metadata supplied by the caller when the object was uploaded, as
well as HTTP metadata such as content length and content type.getObjectContent()public void setObjectMetadata(ObjectMetadata metadata)
NOTE: This does not update the object metadata stored in Qcloud COS, but only updates
this object in local memory. To update an object's metadata in COS, use
COS#copyObject(CopyObjectRequest) to copy the object to a new (or the same location)
and specify new object metadata then.
metadata - The new metadata to set for this object in memory.public COSObjectInputStream getObjectContent()
Note: The method is a simple getter and does not actually create a stream. If you retrieve an COSObject, you should close this input stream as soon as possible, because the object contents aren't buffered in memory and stream directly from Qcloud COS. Further, failure to close this stream can cause the request pool to become blocked.
getObjectMetadata(),
setObjectContent(InputStream)public void setObjectContent(COSObjectInputStream objectContent)
objectContent - The input stream containing this object's contents.getObjectContent()public void setObjectContent(InputStream objectContent)
objectContent - The input stream containing this object's contents. Will get wrapped in
an COSObjectInputStream.getObjectContent()public String getBucketName()
setBucketName(String)public void setBucketName(String bucketName)
bucketName - The name of the bucket containing this object.getBucketName()public String getKey()
setKey(String)public void setKey(String key)
key - The key under which this object is stored.getKey()public String toString()
toString in class ObjectObject.toString()public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException - if an I/O error occursCopyright © 2023. All rights reserved.