{"rsdb":{"rid":"155946","subhead":"","postdate":"0","aid":"117063","fid":"57","uid":"1","topic":"1","content":"

\u6700\u8fd1\u5728\u505a\u4e00\u4e2a\u65b0\u7684\u9879\u76ee\uff0c\u4eceRDS\u5907\u4efd\u5230OSS\uff0c\u8fdb\u884c\u6570\u636e\u5907\u4efd\u4ee5\u53ca\u540e\u7eed\u7684\u8fd8\u539f\u3002\u8fd9\u8fb9\u5bf9\u963f\u91cc\u4e91\u7684OSS\u6570\u636e\u4e0a\u4f20\u63a5\u53e3\u8fdb\u884c\u8bf4\u660e\uff0c\u5148\u505a\u4e0b\u7b14\u8bb0\u5148\u7b80\u5355\u4ecb\u7ecd\u4e0bOSS\uff1a<\/p>

\u2460Object<\/strong><\/span><\/p>

\u5728OSS\u4e2d\uff0c\u7528\u6237\u64cd\u4f5c\u7684\u57fa\u672c\u6570\u636e\u5355\u5143\u662fObject\u3002\u5355\u4e2aObject\u6700\u5927\u5141\u8bb8\u5b58\u50a85TB\u7684\u6570\u636e\u3002Object\u5305\u542bkey\u3001meta\u548cdata\u3002\u5176\u4e2d\uff0ckey\u662fObject\u7684\u540d\u5b57\uff1bmeta\u662f\u7528\u6237\u5bf9\u8be5object\u7684\u63cf\u8ff0\uff0c\u7531\u4e00\u7cfb\u5217name-value\u5bf9\u7ec4\u6210\uff1bdata\u662fObject\u7684\u6570\u636e\u3002<\/p>

\u5176\u4e2dObject\u547d\u540d\u89c4\u8303\uff1a\u4f7f\u7528UTF-8\u7f16\u7801\uff1b\u957f\u5ea6\u5fc5\u987b\u57281-1023\u5b57\u8282\u4e4b\u95f4\uff1b\u4e0d\u80fd\u4ee5\u201c\/\u201d\u6216\u8005\u201c\\\u201d\u5b57\u7b26\u5f00\u5934\u3002<\/p>

\u547d\u540ddemo1\uff1aexample.txt \u8fd9\u4e2a\u5728Bucket\u5185\u5b58\u50a8\u7684\u5c31\u662f\u4e00\u4e2a\u6587\u4ef6\u3002<\/p>

\u547d\u540ddemo2\uff1acd\/example.txt \u8fd9\u4e2a\u5728Bucket\u5185\u5b58\u50a8\u7684\u5c31\u662f\u4e00\u4e2a\u6587\u4ef6\u5939\u7684\u5f62\u5f0f\uff0c\u4e00\u7ea7\u76ee\u5f55\u662fcd\uff0c\u4e8c\u7ea7\u76ee\u5f55\u624d\u662f\u6587\u4ef6example.txt\u3002\u7b49\u4e0b\u6211\u4f1a\u5728\u4e0b\u9762\u7684demo\u5b9e\u4f8b\u4e2d\u7ed9\u51fa\u622a\u56fe\u3002<\/p>

\u2461Bucket<\/strong><\/span><\/p>

\u5b58\u50a8\u5728OSS\u4e0a\u7684\u6bcf\u4e2aObject\u5fc5\u987b\u90fd\u5305\u542b\u5728\u67d0\u4e2aBucket\u4e2d\u3002\u8fd9\u4e2a\u53bb\u963f\u91cc\u7684OSS\u4e0a\u6ce8\u518cOSS\u5b9e\u4f53Bucket\u3002\u7cfb\u7edf\u4f1a\u7ed9\u7528\u6237\u5206\u914d\u4e00\u5bf9Access Key ID\u548cAccess Key Secret\uff0c\u79f0\u4e3aID\u5bf9\uff0c\u7528\u4e8e\u6807\u8bc6\u7528\u6237\uff0c\u4e3a\u8bbf\u95eeOSS\u7684\u6bcf\u4e2aBucket\u505a\u7b7e\u540d\u9a8c\u8bc1\u3002<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>

1\uff09\u6587\u4ef6\u5b58\u50a8\u5230OSS\uff1a<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/strong><\/p>

\u6211\u4eec\u4f7f\u7528\u7684\u662fOSSClient\u4e2d\u7684\u65b9\u6cd5<\/span>public PutObjectResult putObject(String bucketName, String key, File file, ObjectMetadata metadata)<\/p>

\u53c2\u6570\u4ecb\u7ecd\uff1a<\/p>

bucketName\uff1a\u4f60\u7684Bucket\u540d\u79f0<\/p>

key:\u5c31\u662f\u4f60\u5b58\u50a8Object\u7684\u8def\u5f84\uff0c\u4e5f\u5c31\u662f\u4e0a\u9762\u4ecb\u7ecd\u7684Object\u547d\u540d\u3002like\uff1a\"example.tar\"<\/p>

file:\u4f60\u5b58\u50a8\u5230OSS\u4e0a\u7684\u6587\u4ef6<\/p>

metadata\uff1aObjectMetaData\u662f\u7528\u6237\u5bf9\u8be5object\u7684\u63cf\u8ff0\uff0c\u7531\u4e00\u7cfb\u5217name-value\u5bf9\u7ec4\u6210\u3002\u8fd9\u91cc\u6211\u4eec\u76f4\u63a5\u8bbe\u4e3a\u7a7a\u3002<\/p>

\u770b\u770bBukect\u7684\u5b58\u50a8\u6548\u679c<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>

\"\"<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>

2\uff09URL\u4e0b\u8f7d\u5185\u5bb9\u5b58\u50a8\u5230OSS\uff1a<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/strong><\/p>

\u6211\u4eec\u4f7f\u7528\u7684\u662fOSSClient\u4e2d\u7684\u65b9\u6cd5<\/span><\/span><\/span><\/span><\/span><\/span><\/span>public PutObjectResult putObject(String bucketName, String key, InputStream input, ObjectMetadata metadata)<\/p>

\u53c2\u6570\u4ecb\u7ecd\uff1a<\/p>

bucketName\uff1a\u4f60\u7684Bucket\u540d\u79f0<\/p>

key:\u5c31\u662f\u4f60\u5b58\u50a8Object\u7684\u8def\u5f84\uff0c\u4e5f\u5c31\u662f\u4e0a\u9762\u4ecb\u7ecd\u7684Object\u547d\u540d\u3002like\uff1a\"cd\/example.tar\"<\/p>

input:\u4e5f\u5c31\u662f\u8f93\u5165\u6d41\uff0c\u8fd9\u4e2a\u6211\u4eec\u628aUrl\u5185\u5bb9\u5b58\u50a8\u5230OSS\u7684Bukect\u4e0a\uff0c\u5176\u5b9e\u4e5f\u5c31\u662f\u8f6c\u5316\u4e3a\u6d41\u7684\u65b9\u5f0f\u8fdb\u884c\u5b58\u50a8\u7684\u3002\u8fd9\u6837\u505a\u7684\u76ee\u7684\u4e3b\u8981\u5c31\u662furl\u4e0b\u8f7dFile\uff0c\u628aFile\u4e0a\u4f20\u5230OSS\uff0c\u8fd9\u6837\u4f1a\u5927\u5927\u5f71\u54cd\u5b58\u50a8\u901f\u7387\u3002\u6240\u4ee5\u5728\u9879\u76ee\u4e2d\u6570\u636e\u5907\u4efd\u90fd\u662f\u901a\u8fc7\u6d41\u7684\u65b9\u5f0f\uff0c\u800c\u4e0d\u662f\u5efa\u7acb\u4e2d\u95f4\u4e34\u65f6\u6587\u4ef6\u3002<\/p>

metadata\uff1aObjectMetaData\u662f\u7528\u6237\u5bf9\u8be5object\u7684\u63cf\u8ff0\uff0c\u7531\u4e00\u7cfb\u5217name-value\u5bf9\u7ec4\u6210\u3002\u8fd9\u91cc\u6211\u4eec\u76f4\u63a5\u8bbe\u4e3a\u7a7a\u3002<\/p>

\u6ce8\uff1a\u83b7\u53d6\u6d41\u7684\u65b9\u6cd5\u9664\u4e86\u6211\u4e0b\u9762\u5199\u7684\uff0c\u8fd8\u6709\u6211\u6ce8\u91ca\u6389\u7684bis = url.openStream()\u8fd9\u79cd\u65b9\u6cd5\u540c\u6837\u53ef\u4ee5\u83b7\u53d6\u5230InputStream\u3002<\/p>

\u4e0b\u9762\u76f4\u63a5\u770b\u4e0b\u5b58\u50a8\u7684Bucket\u6548\u679c\u5427<\/p>

\"\"<\/p>

\u8fd9\u8fb9\u6211\u8bf4\u4e00\u4e2a\u8fd9\u4e2a\u7a0b\u5e8f\u5f88\u5947\u602a\u7684\u95ee\u9898\uff0c\u8fd9\u8fb9\u6211\u81ea\u5df1\u5f04\u4e86\u597d\u4e45\u3002OSS\u7684\u8bbf\u95eeendPoint\u5730\u5740\uff0c\u6211\u7684Bucket\u4e0a\u4fe1\u606f\u663e\u793aoss-cn-hangzhou-am24-a.**.lab.com\uff0c\u7528\u8fd9\u4e2a\u5730\u5740\u4e00\u76f4\u4e0d\u80fd\u4e0a\u4f20\uff0c\u4e4b\u540e\u6211\u6539\u6210\u5730\u5740\u524d\u9762\u52a0BucketName\uff1abucket-for-rds.oss-cn-hangzhou-am24-a.**.lab.com\u624d\u597d\u4f7f\u3002<\/p>

\u3000\u3000\u8fd9\u4e2a\u9047\u5230\u7684\u540c\u5b66\u8fd8\u53ef\u4ee5\u5c1d\u8bd5endPoint\u524d\u9762\u52a0BukectName\uff0c\u8fd9\u4e2a\u6211\u731c\u6d4b\u53ef\u80fd\u662f\u516c\u6709\u4e91\u548c\u79c1\u6709\u4e91\u7684\u533a\u522b\uff0c\u6709\u4e86\u89e3\u7684\u540c\u5b66\u53ef\u4ee5\u4ea4\u6d41\u4e00\u4e0b\u3002\u6700\u8fd1\u4e00\u76f4\u5728\u505a\u6570\u636e\u5b58\u50a8\u65b9\u9762\u7684\u9879\u76ee\uff0c\u5982\u679c\u63cf\u8ff0\u6216\u8005\u7a0b\u5e8f\u6709\u9519\uff0c\u8bf7\u6307\u51fa\uff0c\u8c22\u8c22~<\/p>","orderid":"0","title":"\u963f\u91cc\u4e91\u6570\u636e\u5907\u4efd\u7684OSS\u63a5\u53e3","smalltitle":"","mid":"0","fname":"\u6570\u636e\u5e93\u7f16\u7a0b","special_id":"0","bak_id":"0","info":"0","hits":"44","pages":"1","comments":"0","posttime":"2017-01-02 08:14:58","list":"1483316098","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"http:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u963f\u91cc<\/A> \u6570\u636e\u5907\u4efd<\/A> OSS<\/A> \u63a5\u53e3<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.31","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u963f\u91cc\u4e91\u6570\u636e\u5907\u4efd\u7684OSS\u63a5\u53e3","lastview":"1487330028","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}