Managing Object Metadata
Scenarios
Object metadata is a set of name-value pairs that describe the object, and are used for object management.
Currently, only the metadata defined by the system is supported.
The metadata defined by the system is classified into the following types: system-controlled and user-controlled. For example, metadata such as Last-Modified is controlled by the system and cannot be modified. You can modify the metadata such as ContentLanguage through the API. The metadata that can be modified is described as follows:
Name |
Description |
---|---|
ContentDisposition |
Provides a default file name for the object that is being requested. When an object is being downloaded or accessed, the file with the default file name is directly displayed in the browser or a download dialog box is displayed if the file is being accessed. For example, select ContentDisposition as the metadata name and enter attachment;filename="testfile.xls" as the metadata value for an object. If you access the object through a link, a dialog box is directly displayed for downloading objects, and the object name is changed to testfile.xls. For details, see the definition about ContentDisposition in HTTP. |
ContentLanguage |
Indicates the language or languages intended for the audience. Therefore, a user can differentiate according to the user's preferred language. For details, see the definition about ContentLanguage in HTTP. |
WebsiteRedirectLocation |
Redirects an object to another object or an external URL. The redirection function is implemented using static website hosting. For example, you can perform the following operations to implement object redirection:
|
ContentEncoding |
Content encoding format when an object is downloaded. The options are as follows:
|
CacheControl |
Cache behavior of the web page when the specified object is downloaded.
|
Expires |
Cache expiration time (GMT) |
ContentType |
File type of an object. For details, see Object Metadata Content-Type. |
- When versioning is enabled for a bucket, you can set metadata for objects which are Latest Version, but cannot set metadata for objects which are Historical Version.
- You cannot configure object metadata for an Archive object.
Object Metadata Content-Type
When an object is uploaded to OBS through OBS Console or a tool, the system automatically matches the value of Content-Type based on the file name extension of the object. When you access an object through a web browser, the system specifies an application to open the object according to the value of Content-Type. You can modify the Content-Type of an object based on its file name extension.
If you upload an object by calling an API, specify the value of Content-Type because the system does not automatically match the value of Content-Type.
File Name Extension |
Content-Type |
File Name Extension |
Content-Type |
---|---|---|---|
.* (binary stream, unknown file type) |
application/octet-stream |
.7z |
application/x-7z-compressed |
.001 |
application/x-001 |
.301 |
application/x-301 |
.323 |
text/h323 |
.906 |
application/x-906 |
.907 |
drawing/907 |
.a11 |
application/x-a11 |
.acp |
audio/x-mei-aac |
.ai |
application/postscript |
.aif |
audio/aiff |
.aifc |
audio/aiff |
.aiff |
audio/aiff |
.anv |
application/x-anv |
.asa |
text/asa |
.asf |
video/x-ms-asf |
.asp |
text/asp |
.asx |
video/x-ms-asf |
.au |
audio/basic |
.avi |
video/avi |
.awf |
application/vnd.adobe.workflow |
.biz |
text/xml |
.bmp |
application/x-bmp |
.bot |
application/x-bot |
.c4t |
application/x-c4t |
.c90 |
application/x-c90 |
.cal |
application/x-cals |
.cat |
application/vnd.ms-pki.seccat |
.cdf |
application/x-netcdf |
.cdr |
application/x-cdr |
.cel |
application/x-cel |
.cer |
application/x-x509-ca-cert |
.cg4 |
application/x-g4 |
.cgm |
application/x-cgm |
.cit |
application/x-cit |
.class |
java/* |
.cml |
text/xml |
.cmp |
application/x-cmp |
.cmx |
application/x-cmx |
.cot |
application/x-cot |
.crl |
application/pkix-crl |
.crt |
application/x-x509-ca-cert |
.csi |
application/x-csi |
.css |
text/css |
.cut |
application/x-cut |
.dbf |
application/x-dbf |
.dbm |
application/x-dbm |
.dbx |
application/x-dbx |
.dcd |
text/xml |
.dcx |
application/x-dcx |
.der |
application/x-x509-ca-cert |
.dgn |
application/x-dgn |
.dib |
application/x-dib |
.dll |
application/x-msdownload |
.doc |
application/msword |
.docx |
application/vnd.openxmlformats-officedocument.wordprocessingml.document |
.drw |
application/x-drw |
.dot |
application/msword |
.dwf |
Model/vnd.dwf |
.dtd |
text/xml |
.dwg |
application/x-dwg |
.dwf |
application/x-dwf |
.dxf |
application/x-dxf |
.dxb |
application/x-dxb |
.emf |
application/x-emf |
.edn |
application/vnd.adobe.edn |
.ent |
text/xml |
.eml |
message/rfc822 |
.eps |
application/x-ps |
.epi |
application/x-epi |
.etd |
application/x-ebx |
.eps |
application/postscript |
.fax |
image/fax |
.exe |
application/x-msdownload |
.fif |
application/fractals |
.fdf |
application/vnd.fdf |
.frm |
application/x-frm |
.fo |
text/xml |
.gbr |
application/x-gbr |
.g4 |
application/x-g4 |
.gif |
image/gif |
. |
application/x- |
.gp4 |
application/x-gp4 |
.gl2 |
application/x-gl2 |
.hmr |
application/x-hmr |
.hgl |
application/x-hgl |
.hpl |
application/x-hpl |
.hpg |
application/x-hpgl |
.hrf |
application/x-hrf |
.hqx |
application/mac-binhex40 |
.htc |
text/x-component |
.hta |
application/hta |
.html |
text/html |
.htm |
text/html |
.htx |
text/html |
.htt |
text/webviewhtml |
.ico |
image/x-icon |
.icb |
application/x-icb |
.iff |
application/x-iff |
.ico |
application/x-ico |
.igs |
application/x-igs |
.ig4 |
application/x-g4 |
.img |
application/x-img |
.iii |
application/x-iphone |
.isp |
application/x-internet-signup |
.ins |
application/x-internet-signup |
.java |
java/* |
.IVF |
video/x-ivf |
.jpe |
image/jpeg |
.jfif |
image/jpeg |
.jpeg |
image/jpeg |
.jpe |
application/x-jpe |
.jpg |
application/x-jpg |
.jpg |
image/jpeg |
.jsp |
text/html |
.js |
text/javascript |
.lar |
application/x-laplayer-reg |
.la1 |
audio/x-liquid-file |
.lavs |
audio/x-liquid-secure |
.latex |
application/x-latex |
.lmsff |
audio/x-la-lms |
.lbm |
application/x-lbm |
.ltr |
application/x-ltr |
.ls |
application/x-javascript |
.m2v |
video/x-mpeg |
.m1v |
video/x-mpeg |
.m4e |
video/mpeg4 |
.m3u |
audio/mpegurl |
.man |
application/x-troff-man |
.mac |
application/x-mac |
.mdb |
application/msaccess |
.math |
text/xml |
.mfp |
application/x-shockwave-flash |
.mdb |
application/x-mdb |
.mhtml |
message/rfc822 |
.mht |
message/rfc822 |
.mid |
audio/mid |
.mi |
application/x-mi |
.mil |
application/x-mil |
.midi |
audio/mid |
.mnd |
audio/x-musicnet-download |
.mml |
text/xml |
.mocha |
application/x-javascript |
.mns |
audio/x-musicnet-stream |
.mp1 |
audio/mp1 |
.movie |
video/x-sgi-movie |
.mp2v |
video/mpeg |
.mp2 |
audio/mp2 |
.mp4 |
video/mp4 |
.mp3 |
audio/mp3 |
.mpd |
application/vnd.ms-project |
.mpa |
video/x-mpg |
.mpeg |
video/mpg |
.mpe |
video/x-mpeg |
.mpga |
audio/rn-mpeg |
.mpg |
video/mpg |
.mps |
video/x-mpeg |
.mpp |
application/vnd.ms-project |
.mpv |
video/mpg |
.mpt |
application/vnd.ms-project |
.mpw |
application/vnd.ms-project |
.mpv2 |
video/mpeg |
.mtx |
text/xml |
.mpx |
application/vnd.ms-project |
.net |
image/pnetvue |
.mxp |
application/x-mmxp |
.nws |
message/rfc822 |
.nrf |
application/x-nrf |
.out |
application/x-out |
.odc |
text/x-ms-odc |
.p12 |
application/x-pkcs12 |
.p10 |
application/pkcs10 |
.p7c |
application/pkcs7-mime |
.p7b |
application/x-pkcs7-certificates |
.p7r |
application/x-pkcs7-certreqresp |
.p7m |
application/pkcs7-mime |
.pc5 |
application/x-pc5 |
.p7s |
application/pkcs7-signature |
.pcl |
application/x-pcl |
.pci |
application/x-pci |
|
application/pdf |
.pcx |
application/x-pcx |
.pdx |
application/vnd.adobe.pdx |
.pfx |
application/x-pkcs12 |
.pgl |
application/x-pgl |
.pic |
application/x-pic |
.pko |
application/vnd.ms-pki.pko |
.pl |
application/x-perl |
.plg |
text/html |
.pls |
audio/scpls |
.plt |
application/x-plt |
.png |
image/png |
.png |
application/x-png |
.pot |
application/vnd.ms-powerpoint |
.ppa |
application/vnd.ms-powerpoint |
.ppm |
application/x-ppm |
.pps |
application/vnd.ms-powerpoint |
.ppt |
application/vnd.ms-powerpoint |
.ppt |
application/x-ppt |
.pr |
application/x-pr |
.prf |
application/pics-rules |
.prn |
application/x-prn |
.prt |
application/x-prt |
.ps |
application/x-ps |
.ps |
application/postscript |
.ptn |
application/x-ptn |
.pwz |
application/vnd.ms-powerpoint |
.r3t |
text/vnd.rn-realtext3d |
.ra |
audio/vnd.rn-realaudio |
.ram |
audio/x-pn-realaudio |
.ras |
application/x-ras |
.rat |
application/rat-file |
.rdf |
text/xml |
.rec |
application/vnd.rn-recording |
.red |
application/x-red |
.rgb |
application/x-rgb |
.rjs |
application/vnd.rn-realsystem-rjs |
.rjt |
application/vnd.rn-realsystem-rjt |
.rlc |
application/x-rlc |
.rle |
application/x-rle |
.rm |
application/vnd.rn-realmedia |
.rmf |
application/vnd.adobe.rmf |
.rmi |
audio/mid |
.rmj |
application/vnd.rn-realsystem-rmj |
.rmm |
audio/x-pn-realaudio |
.rmp |
application/vnd.rn-rn_music_package |
.rms |
application/vnd.rn-realmedia-secure |
.rmvb |
application/vnd.rn-realmedia-vbr |
.rmx |
application/vnd.rn-realsystem-rmx |
.rnx |
application/vnd.rn-realplayer |
.rp |
image/vnd.rn-realpix |
.rpm |
audio/x-pn-realaudio-plugin |
.rsml |
application/vnd.rn-rsml |
.rt |
text/vnd.rn-realtext |
.rtf |
application/msword |
.rtf |
application/x-rtf |
.rv |
video/vnd.rn-realvideo |
.sam |
application/x-sam |
.sat |
application/x-sat |
.sdp |
application/sdp |
.sdw |
application/x-sdw |
.sit |
application/x-stuffit |
.slb |
application/x-slb |
.sld |
application/x-sld |
.slk |
drawing/x-slk |
.smi |
application/smil |
.smil |
application/smil |
.smk |
application/x-smk |
.snd |
audio/basic |
.sol |
text/plain |
.sor |
text/plain |
.spc |
application/x-pkcs7-certificates |
.spl |
application/futuresplash |
.spp |
text/xml |
.ssm |
application/streamingmedia |
.sst |
application/vnd.ms-pki.certstore |
.stl |
application/vnd.ms-pki.stl |
.stm |
text/html |
.sty |
application/x-sty |
.svg |
text/svg+xml |
.swf |
application/x-shockwave-flash |
.tdf |
application/x-tdf |
.tg4 |
application/x-tg4 |
.tga |
application/x-tga |
.tif |
image/tiff |
.tif |
application/x-tif |
.tiff |
image/tiff |
.tld |
text/xml |
.top |
drawing/x-top |
.torrent |
application/x-bittorrent |
.tsd |
text/xml |
.txt |
text/plain |
.uin |
application/x-icq |
.uls |
text/iuls |
.vcf |
text/x-vcard |
.vda |
application/x-vda |
.vdx |
application/vnd.visio |
.vml |
text/xml |
.vpg |
application/x-vpeg005 |
.vsd |
application/vnd.visio |
.vsd |
application/x-vsd |
.vss |
application/vnd.visio |
.vst |
application/vnd.visio |
.vst |
application/x-vst |
.vsw |
application/vnd.visio |
.vsx |
application/vnd.visio |
.vtx |
application/vnd.visio |
.vxml |
text/xml |
.wav |
audio/wav |
.wax |
audio/x-ms-wax |
.wb1 |
application/x-wb1 |
.wb2 |
application/x-wb2 |
.wb3 |
application/x-wb3 |
.wbmp |
image/vnd.wap.wbmp |
.wiz |
application/msword |
.wk3 |
application/x-wk3 |
.wk4 |
application/x-wk4 |
.wkq |
application/x-wkq |
.wks |
application/x-wks |
.wm |
video/x-ms-wm |
.wma |
audio/x-ms-wma |
.wmd |
application/x-ms-wmd |
.wmf |
application/x-wmf |
.wml |
text/vnd.wap.wml |
.wmv |
video/x-ms-wmv |
.wmx |
video/x-ms-wmx |
.wmz |
application/x-ms-wmz |
.wp6 |
application/x-wp6 |
.wpd |
application/x-wpd |
.wpg |
application/x-wpg |
.wpl |
application/vnd.ms-wpl |
.wq1 |
application/x-wq1 |
.wr1 |
application/x-wr1 |
.wri |
application/x-wri |
.wrk |
application/x-wrk |
.ws |
application/x-ws |
.ws2 |
application/x-ws |
.wsc |
text/scriptlet |
.wsdl |
text/xml |
.wvx |
video/x-ms-wvx |
.xdp |
application/vnd.adobe.xdp |
.xdr |
text/xml |
.xfd |
application/vnd.adobe.xfd |
.xfdf |
application/vnd.adobe.xfdf |
.xhtml |
text/html |
.xls |
application/vnd.ms-excel |
.xls |
application/x-xls |
.xlw |
application/x-xlw |
.xml |
text/xml |
.xpl |
audio/scpls |
.xq |
text/xml |
.xql |
text/xml |
.xquery |
text/xml |
.xsd |
text/xml |
.xsl |
text/xml |
.xslt |
text/xml |
.xwd |
application/x-xwd |
.x_b |
application/x-x_b |
.sis |
application/vnd.symbian.install |
.sisx |
application/vnd.symbian.install |
.x_t |
application/x-x_t |
.ipa |
application/vnd.iphone |
.apk |
application/vnd.android.package-archive |
.xap |
application/x-silverlight-app |
.zip |
application/zip |
.rar |
application/x-rar-compressed |
User-Defined Object Metadata
You can add the user-defined metadata whose name starts with x-obs-meta- for easy object management. When you retrieve or query the metadata of the object, the added user-defined metadata will be returned in the response header. The user-defined metadata is limited to 8 KB in size. To measure the total size of user-defined metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
The user-defined metadata keys are case insensitive, but are stored in lowercase by OBS. The key values are case sensitive.
The following is an example.
1 2 3 4 5 6 7 |
PUT /key HTTP/1.1 Host: bucket01.obs.myhuaweicloud.com x-obs-meta-Test1: Test Meta1 HEAD /Key HTTP/1.1 Host: bucket01.obs.myhuaweicloud.com x-obs-meta-test1: Test Meta1 |
Both user-defined metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are necessary, they must be encoded or decoded in URL or Base64 on the client side, because the server side does not perform any decoding.
How to Use
You can use OBS Console, APIs, SDKs, or obsutil to customize object metadata.
Tool |
Reference |
---|---|
OBS Console |
|
SDKs |
OBS supports software development kits (SDKs) in multiple languages. For details, see the corresponding developer guide on the SDK Overview page. |
API |
|
obsutil |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.