管理对象元数据
使用场景
元数据(Metadata)为描述对象属性的信息,是一组名称值对,用作对象管理的一部分。
当前仅支持系统定义的元数据。
系统定义的元数据又分为两种类别:系统控制和用户控制。如Last-Modified日期等数据由系统控制,不可修改;如为对象配置的ContentLanguage,用户可以通过接口进行修改。用户可控制修改的元数据描述如下:
名称 |
说明 |
---|---|
ContentDisposition |
为请求的对象提供一个默认的文件名赋值给该对象,当下载对象或者访问对象时,以默认文件名命名的文件将直接在浏览器上显示或在访问时弹出文件下载对话框。 例如:元数据名称选择为“ContentDisposition”,元数据值填写为“attachment;filename="testfile.xls"”,当通过链接访问设置了该元数据的对象时,会直接弹出一个对象下载的对话框,且对象名称会被修改为“testfile.xls”。 详情请参见HTTP协议中关于ContentDisposition的定义。 |
ContentLanguage |
说明访问者希望采用的语言或语言组合,以根据自己偏好的语言来定制。详情请参见HTTP协议中关于ContentLanguage的定义。 |
WebsiteRedirectLocation |
为对象提供重定向功能,重定向到其他对象或者外部的URL。重定向功能通过静态网站托管实现。 例如,可根据如下步骤实现对象重定向功能。
|
ContentEncoding |
指定对象被下载时的内容编码格式,可以设置如下类型:
|
CacheControl |
指定对象被下载时的网页的缓存行为。
|
Expires |
设置缓存过期时间(GMT)。 |
ContentType |
设置对象的文件类型。 详情请参见对象元数据Content-Type介绍。 |
- 当桶开启多版本控制时,最新版本的对象支持设置元数据,历史版本的对象不支持设置元数据。
- 对于存储类别为归档存储或深度归档存储的对象,不能对其设置对象的元数据。
对象元数据Content-Type介绍
使用控制台和工具上传到OBS中的对象,会根据对象的文件扩展名,自动匹配Content-Type值。使用浏览器访问对象时,会根据Content-Type类型来指定应用程序来打开。您可以根据对象的文件扩展来修改Content-Type。
调用API上传对象时,不会自动匹配Content-Type值,需要指定Content-Type值。
文件扩展名 |
Content-Type |
文件扩展名 |
Content-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 |
对象自定义元数据介绍
OBS支持用户使用以“x-obs-meta-”开头的消息头来加入自定义的元数据,以便对对象进行自定义管理。当用户获取此对象或查询此对象元数据时,加入的自定义元数据将会在返回的消息头中出现。自定义元数据大小限制为8K,计算方式为:每个键和值的UTF-8 编码中的字节总数来测量用户定义的元数据的大小。
自定义元数据的key值不区分大小写,OBS统一转为小写进行存储。value值区分大小写。
示例:
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 |
自定义元数据key-value对都必须符合US-ASCII。如果一定要使用非ASCII码或不可识别字符,需要客户端自行做编解码处理,可以采用URL编码或者Base64编码,服务端不会做解码处理。