
{"id":963,"date":"2020-08-11T11:27:41","date_gmt":"2020-08-11T03:27:41","guid":{"rendered":"https:\/\/www.changxuan.top\/?p=963"},"modified":"2020-10-12T20:30:19","modified_gmt":"2020-10-12T12:30:19","slug":"spring-boot-%e9%9b%86%e6%88%90-amazons3-%e5%ad%98%e5%82%a8%e6%9c%8d%e5%8a%a1%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.changxuan.top\/?p=963","title":{"rendered":"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b"},"content":{"rendered":"<section id=\"nice\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\" style=\"font-size: 16px; color: black; padding: 0 10px; line-height: 1.6; word-spacing: 0px; letter-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;\">\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\n<div class=\"table-of-contents\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<ul style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;\">\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u73af\u5883\u51c6\u5907<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u5f00\u59cb\u4f7f\u7528<\/a>\n<ul style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: square;\">\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">1. \u5f15\u5165\u4f9d\u8d56<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">2. \u521d\u59cb\u5316<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">3. \u4f9d\u8d56\u6ce8\u5165<\/a><\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">4. \u6587\u4ef6\u64cd\u4f5c<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"\" style=\"text-decoration: none; word-wrap: break-word; border-bottom: 1px solid #1e6bb8; border: none; color: black; font-weight: normal;\">\u53c2\u8003\u8d44\u6599<\/a><\/li>\n<\/ul>\n<\/div>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 22px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u73af\u5883\u51c6\u5907<\/span><span class=\"suffix\"><\/span><\/h2>\n<ol data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: decimal;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;\">Java\u73af\u5883\uff1aJDK6\u4ee5\u4e0a\u7248\u672c<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;\">SpringBoot 2.2.5<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;\">\u5b58\u50a8\u670d\u52a1\u7684 accessKey\u3001secreKey \u4ee5\u53ca \u5730\u5740:\u7aef\u53e3<\/section>\n<\/li>\n<\/ol>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 22px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u5f00\u59cb\u4f7f\u7528<\/span><span class=\"suffix\"><\/span><\/h2>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">1. \u5f15\u5165\u4f9d\u8d56<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u5728 <code style=\"font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; color: #1e6bb8; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all;\">pom.xml<\/code> \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e0b\u5217\u4f9d\u8d56\uff1a<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-tag\" style=\"line-height: 26px;\">&lt;<span class=\"hljs-name\" style=\"color: #e06c75; line-height: 26px;\">dependency<\/span>&gt;<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-tag\" style=\"line-height: 26px;\">&lt;<span class=\"hljs-name\" style=\"color: #e06c75; line-height: 26px;\">groupId<\/span>&gt;<\/span>com.amazonaws<span class=\"hljs-tag\" style=\"line-height: 26px;\">&lt;\/<span class=\"hljs-name\" style=\"color: #e06c75; line-height: 26px;\">groupId<\/span>&gt;<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-tag\" style=\"line-height: 26px;\">&lt;<span class=\"hljs-name\" style=\"color: #e06c75; line-height: 26px;\">artifactId<\/span>&gt;<\/span>aws-java-sdk<span class=\"hljs-tag\" style=\"line-height: 26px;\">&lt;\/<span class=\"hljs-name\" style=\"color: #e06c75; line-height: 26px;\">artifactId<\/span>&gt;<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-tag\" style=\"line-height: 26px;\">&lt;<span class=\"hljs-name\" style=\"color: #e06c75; line-height: 26px;\">version<\/span>&gt;<\/span>1.11.433<span class=\"hljs-tag\" style=\"line-height: 26px;\">&lt;\/<span class=\"hljs-name\" style=\"color: #e06c75; line-height: 26px;\">version<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"line-height: 26px;\">&lt;\/<span class=\"hljs-name\" style=\"color: #e06c75; line-height: 26px;\">dependency<\/span>&gt;<\/span>\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">2. \u521d\u59cb\u5316<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<h4 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">&gt; \u7b80\u5355\u6a21\u5f0f<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h4>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">String&nbsp;accessKey&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-accesskey\"<\/span>;\nString&nbsp;secretKey&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-secretKey\"<\/span>;\n\nAWSCredentials&nbsp;credentials&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;BasicAWSCredentials(accessKey,&nbsp;secretKey);\nAmazonS3&nbsp;conn&nbsp;=&nbsp;AmazonS3ClientBuilder.standard()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withCredentials(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;AWSStaticCredentialsProvider(credentials))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withEndpointConfiguration(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;AwsClientBuilder.EndpointConfiguration(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"endpoint\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"region\"<\/span>))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.build();\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u793a\u4f8b\uff1a<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">String&nbsp;accessKey&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"TPDDEA5PCT9C8RUPKAWW\"<\/span>;\nString&nbsp;secretKey&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"ryesPMSiSfOzaP1TkFe9TIOBnxpdrA2sw6isFwDZ\"<\/span>;\n\nAWSCredentials&nbsp;credentials&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;BasicAWSCredentials(accessKey,&nbsp;secretKey);\nAmazonS3&nbsp;conn&nbsp;=&nbsp;AmazonS3ClientBuilder.standard()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withCredentials(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;AWSStaticCredentialsProvider(credentials))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withEndpointConfiguration(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;&nbsp;&nbsp;AwsClientBuilder.EndpointConfiguration(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"http:\/\/10.200.100.37:7480\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"region\"<\/span>))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.build();\n<\/code><\/pre>\n<h4 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">&gt; \u914d\u7f6e\u6a21\u5f0f<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h4>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.ClientConfiguration;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.Protocol;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.auth.AWSCredentials;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.auth.AWSStaticCredentialsProvider;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.auth.BasicAWSCredentials;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.client.builder.AwsClientBuilder;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.services.s3.AmazonS3;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.services.s3.AmazonS3ClientBuilder;\n\nString&nbsp;accessKey&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-accesskey\"<\/span>;\nString&nbsp;secretKey&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-secretKey&nbsp;\"<\/span>;\nAWSCredentials&nbsp;credentials&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;BasicAWSCredentials(accessKey,secretKey);\nClientConfiguration&nbsp;conf&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;ClientConfiguration();\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8bbe\u7f6eAmazonS3\u4f7f\u7528\u7684\u6700\u5927\u8fde\u63a5\u6570<\/span>\nconf.setMaxConnections(<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">200<\/span>);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8bbe\u7f6esocket\u8d85\u65f6\u65f6\u95f4<\/span>\nconf.setSocketTimeout(<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">10000<\/span>);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8bbe\u7f6e\u5931\u8d25\u8bf7\u6c42\u91cd\u8bd5\u6b21\u6570<\/span>\nconf.setMaxErrorRetry(<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">2<\/span>);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u5982\u679c\u8981\u7528https\u534f\u8bae\uff0c\u8bf7\u52a0\u4e0a\u4e0b\u9762\u8bed\u53e5<\/span>\nconf.setProtocol(Protocol.HTTPS);\n\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/AmazonS3&nbsp;s3Client&nbsp;=&nbsp;new&nbsp;AmazonS3Client(credentials,clientConfiguration);<\/span>\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/s3Client.setEndpoint(endPoint);<\/span>\nAmazonS3&nbsp;s3Client&nbsp;=&nbsp;AmazonS3ClientBuilder.standard()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withCredentials(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;AWSStaticCredentialsProvider(credentials))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withEndpointConfiguration(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;AwsClientBuilder.EndpointConfiguration(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"endpoint\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"region\"<\/span>))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withClientConfiguration(conf)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.build();<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/endpoint,region\u8bf7\u6307\u5b9a\u4e3aNOS\u652f\u6301\u7684<\/span>\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u793a\u4f8b\uff1a<\/p>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"display: block; font-size: 0.9em; overflow: auto; overflow-scrolling: touch; border-left: 3px solid rgba(0, 0, 0, 0.4); background: rgba(0, 0, 0, 0.05); color: #6a737d; padding-top: 10px; padding-bottom: 10px; padding-left: 20px; padding-right: 10px; margin-bottom: 20px; margin-top: 20px;\">\n<p style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0px; color: black; line-height: 26px;\">Amazon3 \u662f\u7ebf\u7a0b\u5b89\u5168\u7684\uff0c\u56e0\u6b64\u53ef\u4ee5\u5c06\u5176\u6ce8\u5165\u5230 Spring \u5bb9\u5668\u4e2d\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<\/blockquote>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">@AmazonS3Config.java<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.ClientConfiguration;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.Protocol;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.auth.AWSCredentials;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.auth.AWSStaticCredentialsProvider;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.auth.BasicAWSCredentials;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.client.builder.AwsClientBuilder;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.services.s3.AmazonS3;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.services.s3.AmazonS3ClientBuilder;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.services.s3.model.CreateBucketRequest;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.services.s3.transfer.TransferManager;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.amazonaws.services.s3.transfer.TransferManagerBuilder;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;org.springframework.beans.factory.annotation.Autowired;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;org.springframework.boot.context.properties.EnableConfigurationProperties;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;org.springframework.context.annotation.Bean;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;org.springframework.context.annotation.Configuration;\n\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Author<\/span>:&nbsp;ChangXuan\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Decription<\/span>:&nbsp;\u521d\u59cb\u5316AmazonS3\u5b9e\u4f8b\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Date<\/span>:&nbsp;17:33&nbsp;2020\/6\/3\n&nbsp;**\/<\/span>\n<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@Configuration<\/span>\n<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@EnableConfigurationProperties<\/span>(UploadConfig.class)\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-class\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">class<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #e6c07b; line-height: 26px;\">AmazonS3Config<\/span>&nbsp;<\/span>{\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@Autowired<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;UploadConfig&nbsp;uploadConfig;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@Bean<\/span>(name&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"amazonS3\"<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">public<\/span>&nbsp;AmazonS3&nbsp;<span class=\"hljs-title\" style=\"color: #61aeee; line-height: 26px;\">getAmazonS3<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">()<\/span><\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;accessKey&nbsp;=&nbsp;uploadConfig.getCeph().getAccessKey();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;secretKey&nbsp;=&nbsp;uploadConfig.getCeph().getSecretKey();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AWSCredentials&nbsp;credentials&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;BasicAWSCredentials(accessKey,secretKey);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ClientConfiguration&nbsp;conf&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;ClientConfiguration();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8bbe\u7f6eAmazonS3\u4f7f\u7528\u7684\u6700\u5927\u8fde\u63a5\u6570<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conf.setMaxConnections(uploadConfig.getCeph().getAmazonS3MaxConnections());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8bbe\u7f6esocket\u8d85\u65f6\u65f6\u95f4<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conf.setSocketTimeout(uploadConfig.getCeph().getAmazonS3SocketTimeout());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8bbe\u7f6e\u5931\u8d25\u8bf7\u6c42\u91cd\u8bd5\u6b21\u6570<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conf.setMaxErrorRetry(uploadConfig.getCeph().getAmazonS3MaxErrorRetry());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8bbe\u7f6e\u534f\u8bae<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">if<\/span>&nbsp;(!<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"blank\"<\/span>.equals(uploadConfig.getCeph().getAmazonS3Protocol())){\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">switch<\/span>&nbsp;(uploadConfig.getCeph().getAmazonS3Protocol()){\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">case<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"https\"<\/span>:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conf.setProtocol(Protocol.HTTPS);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">break<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">case<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"http\"<\/span>:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conf.setProtocol(Protocol.HTTP);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">break<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">default<\/span>:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">break<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AmazonS3&nbsp;s3Client&nbsp;=&nbsp;AmazonS3ClientBuilder.standard()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withCredentials(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;AWSStaticCredentialsProvider(credentials))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withEndpointConfiguration(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;AwsClientBuilder.EndpointConfiguration(uploadConfig.getCeph().getHosts().get(<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">0<\/span>),uploadConfig.getCeph().getRegion()))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.withClientConfiguration(conf)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.build();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkAndCreateBucket(s3Client);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">return<\/span>&nbsp;s3Client;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@Bean<\/span>(name&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"transferManager\"<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">public<\/span>&nbsp;TransferManager&nbsp;<span class=\"hljs-title\" style=\"color: #61aeee; line-height: 26px;\">getTransferManager<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">()<\/span><\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">return<\/span>&nbsp;TransferManagerBuilder.standard().withS3Client(getAmazonS3()).build();\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u68c0\u67e5\u6876\u662f\u5426\u5b58\u5728\uff0c\u4e0d\u5b58\u5728\u5219\u521b\u5efa\u521b\u5efa\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@param<\/span>&nbsp;s3Client\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-function\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">void<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #61aeee; line-height: 26px;\">checkAndCreateBucket<\/span><span class=\"hljs-params\" style=\"line-height: 26px;\">(AmazonS3&nbsp;s3Client)<\/span><\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">boolean<\/span>&nbsp;exists&nbsp;=&nbsp;s3Client.doesBucketExistV2(uploadConfig.getCeph().getBucketName());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">if<\/span>&nbsp;(!exists){\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CreateBucketRequest&nbsp;request&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;CreateBucketRequest(uploadConfig.getCeph().getBucketName());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s3Client.createBucket(request);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">@UploadConfig.java<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;lombok.Data;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;org.springframework.boot.context.properties.ConfigurationProperties;\n\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Author<\/span>:&nbsp;ChangXuan\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Decription<\/span>:&nbsp;\u4e0a\u4f20&nbsp;\u914d\u7f6e\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Date<\/span>:&nbsp;17:25&nbsp;2020\/6\/3\n&nbsp;**\/<\/span>\n<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@ConfigurationProperties<\/span>(prefix&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"upload\"<\/span>)\n<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@Data<\/span>\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-class\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">class<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #e6c07b; line-height: 26px;\">UploadConfig<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;CephConfig&nbsp;ceph;\n}\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">@CephConfig.java<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;com.google.common.collect.Lists;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;lombok.Data;\n\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">import<\/span>&nbsp;java.util.List;\n\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Author<\/span>:&nbsp;ChangXuan\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Decription<\/span>:\u914d\u7f6e\n&nbsp;*&nbsp;<span class=\"hljs-doctag\" style=\"color: #c678dd; line-height: 26px;\">@Date<\/span>:&nbsp;17:28&nbsp;2020\/6\/3\n&nbsp;**\/<\/span>\n<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@Data<\/span>\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">public<\/span>&nbsp;<span class=\"hljs-class\" style=\"line-height: 26px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">class<\/span>&nbsp;<span class=\"hljs-title\" style=\"color: #e6c07b; line-height: 26px;\">CephConfig<\/span>&nbsp;<\/span>{\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u96c6\u7fa4ip:port\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;List&lt;String&gt;&nbsp;hosts&nbsp;=&nbsp;Lists.newArrayList();\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;String&nbsp;accessKey;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;String&nbsp;secretKey;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;String&nbsp;region;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u8fde\u63a5\u534f\u8bae\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;String&nbsp;amazonS3Protocol;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u5931\u8d25\u8bf7\u6c42\u91cd\u8bd5\u6b21\u6570\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;Integer&nbsp;amazonS3MaxErrorRetry;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u8d85\u65f6\u65f6\u95f4\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;Integer&nbsp;amazonS3SocketTimeout;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u6700\u5927\u8fde\u63a5\u6570\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;Integer&nbsp;amazonS3MaxConnections;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u6876\u540d\u79f0\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;String&nbsp;bucketName;\n\n}\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">@application.yml<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">upload:<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;ceph:<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;bucketName:<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">ic-storage-dev<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;region:<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">region<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;hosts:<\/span>\n<span class=\"hljs-bullet\" style=\"color: #61aeee; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"10.200.100.37:7480\"<\/span>\n<span class=\"hljs-bullet\" style=\"color: #61aeee; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"10.200.100.38:7480\"<\/span>\n<span class=\"hljs-bullet\" style=\"color: #61aeee; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"10.200.100.39:7480\"<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;accessKey:<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">TPDDEA5PCT9C8RUPKAWW<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;secretKey:<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">ryesPMSiSfOzaP1TkFe9TIWQnxpdrA2sw6isFwDZ<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;amazonS3MaxConnections:<\/span>&nbsp;<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">200<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;amazonS3SocketTimeout:<\/span>&nbsp;<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">10000<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;amazonS3MaxErrorRetry:<\/span>&nbsp;<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">2<\/span>\n<span class=\"hljs-attr\" style=\"color: #d19a66; line-height: 26px;\">&nbsp;&nbsp;&nbsp;&nbsp;amazonS3Protocol:<\/span>&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">http<\/span>\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">3. \u4f9d\u8d56\u6ce8\u5165<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@Autowired<\/span>\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;AmazonS3&nbsp;amazonS3;\n\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u6216<\/span>\n\n<span class=\"hljs-meta\" style=\"color: #61aeee; line-height: 26px;\">@Autowired<\/span>\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">private<\/span>&nbsp;TransferManager&nbsp;transferManager;\n<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">4. \u6587\u4ef6\u64cd\u4f5c<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h3>\n<h4 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6587\u4ef6\u4e0a\u4f20<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h4>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">1. \u76f4\u63a5\u5185\u5bb9\u4e0a\u4f20<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u8981\u4e0a\u4f20\u6587\u4ef6\u5185\u5bb9<\/span>\nString&nbsp;content&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"Object&nbsp;content\"<\/span>;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;&nbsp;amazonS3.putObject(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>,content);\n}<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(Exception&nbsp;e){\n&nbsp;&nbsp;&nbsp;System.out.println(e.getMessage());\n}\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">2. \u672c\u5730\u6587\u4ef6\u666e\u901a\u4e0a\u4f20<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u5bf9\u4e8e\u5c0f\u5bf9\u8c61\u53ef\u4ee5\u4f7f\u7528putObject\u63a5\u53e3\u8fdb\u884c\u4e0a\u4f20\uff0cputObject\u4e0a\u4f20\u652f\u6301\u7684\u6700\u5927\u6587\u4ef6\u5927\u5c0f\u4e3a100M\uff0c\u5982\u679c\u4e0a\u4f20\u5927\u4e8e100M\u7684\u6587\u4ef6\u9700\u8981\u4f7f\u7528\u5206\u5757\u4e0a\u4f20\u3002\u672c\u5730\u6587\u4ef6\u666e\u901a\u4e0a\u4f20\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u8981\u4e0a\u4f20\u6587\u4ef6\u7684\u8def\u5f84<\/span>\nString&nbsp;filePath&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-local-file-path\"<\/span>;\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;&nbsp;amazonS3.putObject(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>,&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;File(filePath));\n}<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(Exception&nbsp;e){\n&nbsp;&nbsp;&nbsp;System.out.println(e.getMessage());\n}\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">3. \u4e0a\u4f20\u6587\u4ef6\u65f6\u8bbe\u7f6e\u6587\u4ef6\u5143\u6570\u636e\u4fe1\u606f<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">String&nbsp;filePath&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-local-file-path\"<\/span>;\nObjectMetadata&nbsp;objectMetadata&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;ObjectMetadata();\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u8bbe\u7f6eContent-Type<\/span>\nobjectMetadata.setContentType(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"application\/xml\"<\/span>);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u8bbe\u7f6e\u6807\u51c6http\u6d88\u606f\u5934\uff08\u5143\u6570\u636e\uff09<\/span>\nobjectMetadata.setHeader(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"Cache-Control\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"no-cache\"<\/span>);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u8bbe\u7f6e\u7528\u6237\u81ea\u5b9a\u4e49\u5143\u6570\u636e\u4fe1\u606f<\/span>\nMap&lt;String,&nbsp;String&gt;&nbsp;userMeta&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;HashMap&lt;String,&nbsp;String&gt;();\nuserMeta.put(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"ud\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"test\"<\/span>);\nobjectMetadata.setUserMetadata(userMeta);\nPutObjectRequest&nbsp;putObjectRequest&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;PutObjectRequest(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>,&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;File(filePath));\nputObjectRequest.setMetadata(objectMetadata);\namazonS3.putObject(putObjectRequest);\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">4. \u6d41\u5f0f\u4e0a\u4f20<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;&nbsp;ObjectMetadata&nbsp;objectMetadata&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;ObjectMetadata();\n&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u8bbe\u7f6e\u6d41\u7684\u957f\u5ea6\uff0c\u60a8\u8fd8\u53ef\u4ee5\u8bbe\u7f6e\u5176\u4ed6\u6587\u4ef6\u5143\u6570\u636e\u4fe1\u606f<\/span>\n&nbsp;&nbsp;&nbsp;objectMetadata.setContentLength(streamLength);\n&nbsp;&nbsp;&nbsp;amazonS3.putObject(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>,&nbsp;inputStream,&nbsp;objectMetadata)\n}<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(Exception&nbsp;e){\n&nbsp;&nbsp;&nbsp;System.out.println(e.getMessage());\n}\n<\/code><\/pre>\n<h4 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6587\u4ef6\u4e0b\u8f7d<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h4>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">1. \u6d41\u5f0f\u4e0b\u8f7d<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">S3Object&nbsp;fileObject&nbsp;=&nbsp;amazonS3.getObject(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u53ef\u4ee5\u901a\u8fc7getObjectMetadata\u65b9\u6cd5\u83b7\u53d6\u5bf9\u8c61\u7684ContentType\u7b49\u5143\u6570\u636e\u4fe1\u606f<\/span>\nString&nbsp;contentType&nbsp;=&nbsp;fileObject.getObjectMetadata().getContentType();\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u6d41\u5f0f\u83b7\u53d6\u6587\u4ef6\u5185\u5bb9<\/span>\nInputStream&nbsp;in&nbsp;=&nbsp;fileObject.getObjectContent();\nBufferedReader&nbsp;reader&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;BufferedReader(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;InputStreamReader(in));\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">while<\/span>&nbsp;(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">true<\/span>)&nbsp;{\n&nbsp;&nbsp;String&nbsp;line;\n&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;line&nbsp;=&nbsp;reader.readLine();\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">if<\/span>&nbsp;(line&nbsp;==&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">null<\/span>)&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">break<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"\\n\"<\/span>&nbsp;+&nbsp;line);\n&nbsp;&nbsp;}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(IOException&nbsp;e)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();\n&nbsp;&nbsp;}\n}\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;reader.close();\n}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(IOException&nbsp;e)&nbsp;{\n&nbsp;&nbsp;e.printStackTrace();\n}\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">2. \u4e0b\u8f7d\u5230\u672c\u5730\u6587\u4ef6<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">String&nbsp;destinationFile&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-local-filepath\"<\/span>;\nGetObjectRequest&nbsp;getObjectRequest&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;GetObjectRequest(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>);\nObjectMetadata&nbsp;objectMetadata&nbsp;=&nbsp;amazonS3.getObject(getObjectRequest,&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;File(destinationFile));\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">3. Range \u4e0b\u8f7d<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">GetObjectRequest&nbsp;getObjectRequest&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;GetObjectRequest(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>);\ngetObjectRequest.setRange(<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">0<\/span>,&nbsp;<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">100<\/span>);\nS3Object&nbsp;nosObject&nbsp;=&nbsp;amazonS3.getObject(getObjectRequest);\nBufferedReader&nbsp;reader&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;BufferedReader(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;InputStreamReader(in));\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">while<\/span>&nbsp;(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">true<\/span>)&nbsp;{\n&nbsp;&nbsp;String&nbsp;line;\n&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;line&nbsp;=&nbsp;reader.readLine();\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">if<\/span>&nbsp;(line&nbsp;==&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">null<\/span>)&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">break<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"\\n\"<\/span>&nbsp;+&nbsp;line);\n&nbsp;&nbsp;}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(IOException&nbsp;e)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();\n&nbsp;&nbsp;}\n}\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;reader.close();\n}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(IOException&nbsp;e)&nbsp;{\n&nbsp;&nbsp;e.printStackTrace();\n}\n<\/code><\/pre>\n<h4 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6587\u4ef6\u7ba1\u7406<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h4>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u53ef\u4ee5\u901a\u8fc7AmazonS3.doesObjectExist\u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728\u3002<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">boolean<\/span>&nbsp;isExist&nbsp;=&nbsp;amazonS3.doesObjectExist(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>);\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6587\u4ef6\u5220\u9664<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u53ef\u4ee5\u901a\u8fc7AmazonS3.deleteObject\u5220\u9664\u5355\u4e2a\u6587\u4ef6<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">amazonS3.deleteObject(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>);\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7AmazonS3.deleteObjects\u4e00\u6b21\u5220\u9664\u591a\u4e2a\u6587\u4ef6<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;DeleteObjectsResult&nbsp;result&nbsp;=&nbsp;amazonS3.deleteObjects(deleteObjectsRequest);\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;DeletedObject&gt;&nbsp;&nbsp;deleteObjects&nbsp;=&nbsp;result.getDeletedObjects();\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/print&nbsp;the&nbsp;delete&nbsp;results<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">for<\/span>&nbsp;(DeletedObject&nbsp;items:&nbsp;deleteObjects){\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(items.getKey());\n&nbsp;&nbsp;&nbsp;&nbsp;}\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u90e8\u5206\u5bf9\u8c61\u5220\u9664\u5931\u8d25<\/span>\n}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(MultiObjectDeleteException&nbsp;e)&nbsp;{&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;List&lt;DeleteError&gt;&nbsp;deleteErrors&nbsp;=&nbsp;e.getErrors();\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">for<\/span>&nbsp;(DeleteError&nbsp;error&nbsp;:&nbsp;deleteErrors)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(error.getKey());\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(AmazonServiceException&nbsp;&nbsp;e)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u6355\u6349\u670d\u52a1\u5668\u5f02\u5e38\u9519\u8bef<\/span>\n}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(AmazonClientException&nbsp;ace)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u6355\u6349\u5ba2\u6237\u7aef\u9519\u8bef<\/span>\n}\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u83b7\u53d6\u6587\u4ef6\u5143\u6570\u636e\u4fe1\u606f<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u53ef\u4ee5\u901a\u8fc7AmazonS3.getObjectMetadata\u83b7\u53d6\u6587\u4ef6\u5143\u6570\u636e\u4fe1\u606f<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">amazonS3.getObjectMetadata(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>);\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6587\u4ef6\u590d\u5236(copy)<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u53ef\u4ee5\u901a\u8fc7AmazonS3.copyObject\u63a5\u53e3\u5b9e\u73b0\u6587\u4ef6\u62f7\u8d1d\u529f\u80fd\u3002<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">amazonS3.copyObject(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"source-bucket\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"source-object\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"dst-bucket\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"dst-object\"<\/span>);\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u5217\u4e3e\u6876\u5185\u6587\u4ef6<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u53ef\u4ee5\u901a\u8fc7AmazonS3.listObjects\u5217\u51fa\u6876\u91cc\u7684\u6587\u4ef6\u3002listObjects\u63a5\u53e3\u5982\u679c\u8c03\u7528\u6210\u529f\uff0c\u4f1a\u8fd4\u56de\u4e00\u4e2aObjectListing\u5bf9\u8c61\uff0c\u5217\u4e3e\u7684\u7ed3\u679c\u4fdd\u6301\u5728\u8be5\u5bf9\u8c61\u4e2d\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">ObjectListing\u7684\u5177\u4f53\u4fe1\u606f\u5982\u4e0b\u8868\u6240\u793a\uff1a<\/p>\n<section class=\"table-container\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"overflow-x: auto;\">\n<table style=\"display: table; text-align: left;\">\n<thead>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: white;\">\n<th style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; font-weight: bold; background-color: #f0f0f0; min-width: 85px;\">\u65b9\u6cd5<\/th>\n<th style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; font-weight: bold; background-color: #f0f0f0; min-width: 85px; text-align: left;\">\u542b\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody style=\"border: 0;\">\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: white;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;\">List getObjectSummaries()<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u8fd4\u56de\u7684\u6587\u4ef6\u5217\u8868\uff08\u5305\u542b\u6587\u4ef6\u7684\u540d\u79f0\u3001Etag\u7684\u5143\u6570\u636e\u4fe1\u606f\uff09<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;\">String getPrefix()<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u672c\u6b21\u67e5\u8be2\u7684\u6587\u4ef6\u540d\u524d\u7f00<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: white;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;\">String getDelimiter()<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u6587\u4ef6\u5206\u754c\u7b26<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;\">String getMarker()<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u8fd9\u6b21List Objects\u7684\u8d77\u70b9<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: white;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;\">int getMaxKeys()<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u54cd\u5e94\u8bf7\u6c42\u5185\u8fd4\u56de\u7ed3\u679c\u7684\u6700\u5927\u6570\u76ee<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;\">String getNextMarker()<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u4e0b\u4e00\u6b21List Object\u7684\u8d77\u70b9<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: white;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;\">boolean isTruncated()<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u662f\u5426\u622a\u65ad\uff0c\u5982\u679c\u56e0\u4e3a\u8bbe\u7f6e\u4e86limit\u5bfc\u81f4\u4e0d\u662f\u6240\u6709\u7684\u6570\u636e\u96c6\u90fd\u8fd4\u56de\uff0c\u5219\u8be5\u503c\u8bbe\u7f6e\u4e3atrue<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; text-align: left; min-width: 85px;\">List getCommonPrefixes()<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u5982\u679c\u8bf7\u6c42\u4e2d\u6307\u5b9a\u4e86delimiter\u53c2\u6570\uff0c\u5219\u8fd4\u56de\u7684\u5305\u542bCommonPrefixes\u5143\u7d20\u3002\u8be5\u5143\u7d20\u6807\u660e\u4ee5delimiter\u7ed3\u5c3e\uff0c\u5e76\u6709\u5171\u540c\u524d\u7f00\u7684\u5bf9\u8c61\u7684\u96c6\u5408<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/section>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">AmazonS3.listObjects\u63a5\u53e3\u63d0\u4f9b\u4e24\u79cd\u8c03\u7528\u65b9\u5f0f\uff1a\u7b80\u5355\u5217\u4e3e\u3001\u901a\u8fc7ListObjectsRequest\u5217\u4e3e<\/p>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u7b80\u5355\u5217\u4e3e<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u7b80\u5355\u5217\u4e3e\u53ea\u9700\u6307\u5b9a\u9700\u8981\u5217\u4e3e\u7684\u6876\u540d\uff0c\u6700\u591a\u8fd4\u56de100\u6761\u5bf9\u8c61\u8bb0\u5f55\uff0c\u5efa\u8bae\u6876\u5185\u5bf9\u8c61\u6570\u8f83\u5c11\u65f6\uff08\u5c0f\u4e8e100\uff09\u4f7f\u7528\u3002<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">ObjectListing&nbsp;objectListing&nbsp;=&nbsp;amazonS3.listObjects(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>);\nList&lt;S3ObjectSummary&gt;&nbsp;sums&nbsp;=&nbsp;objectListing.getObjectSummaries();\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">for<\/span>&nbsp;(S3ObjectSummary&nbsp;s&nbsp;:&nbsp;sums)&nbsp;{\n&nbsp;&nbsp;System.out.println(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"\\t\"<\/span>&nbsp;+&nbsp;s.getKey());\n}\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u901a\u8fc7ListObjectsRequest\u5217\u4e3e<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6eListObjectsReques\u53c2\u6570\u5b9e\u73b0\u5404\u79cd\u7075\u6d3b\u7684\u67e5\u8be2\u529f\u80fd\u3002ListObjectsReques\u7684\u53ef\u8bbe\u7f6e\u7684\u53c2\u6570\u5982\u4e0b\uff1a<\/p>\n<section class=\"table-container\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"overflow-x: auto;\">\n<table style=\"display: table; text-align: left;\">\n<thead>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: white;\">\n<th style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; font-weight: bold; background-color: #f0f0f0; min-width: 85px; text-align: left;\">\u8bbe\u7f6e\u65b9\u6cd5<\/th>\n<th style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; font-weight: bold; background-color: #f0f0f0; min-width: 85px; text-align: left;\">\u4f5c\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody style=\"border: 0;\">\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: white;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">setPrefix(String prefix)<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u9650\u5b9a\u8fd4\u56de\u7684object key\u5fc5\u987b\u4ee5prefix\u4f5c\u4e3a\u524d\u7f00<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">setDelimiter(String delimiter)<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u662f\u4e00\u4e2a\u7528\u4e8e\u5bf9Object\u540d\u5b57\u8fdb\u884c\u5206\u7ec4\u7684\u5b57\u7b26\u3002\u6240\u6709\u540d\u5b57\u5305\u542b\u6307\u5b9a\u7684\u524d\u7f00\u4e14\u7b2c\u4e00\u6b21\u51fa\u73b0delimiter\u5b57\u7b26\u4e4b\u95f4\u7684object\u4f5c\u4e3a\u4e00\u7ec4\u5143\u7d20\u2014\u2014CommonPrefixes<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: white;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">setMarker(String marker)<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u5b57\u5178\u5e8f\u7684\u8d77\u59cb\u6807\u8bb0\uff0c\u53ea\u5217\u51fa\u8be5\u6807\u8bb0\u4e4b\u540e\u7684\u90e8\u5206<\/td>\n<\/tr>\n<tr style=\"border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8;\">\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">setMaxKeys(Integer maxKeys)<\/td>\n<td style=\"font-size: 16px; border: 1px solid #ccc; padding: 5px 10px; min-width: 85px; text-align: left;\">\u9650\u5b9a\u8fd4\u56de\u7684\u6570\u91cf\uff0c\u8fd4\u56de\u7684\u7ed3\u679c\u5c0f\u4e8e\u6216\u7b49\u4e8e\u8be5\u503c(\u9ed8\u8ba4\u503c\u4e3a100)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/section>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">1\u3001\u5206\u9875\u5217\u4e3e\u6876\u5185\u7684\u6240\u6709\u6587\u4ef6\uff1a<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">List&lt;S3ObjectSummary&gt;&nbsp;listResult&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;ArrayList&lt;S3ObjectSummary&gt;();\nListObjectsRequest&nbsp;listObjectsRequest&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;ListObjectsRequest();\nlistObjectsRequest.setBucketName(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>);\nlistObjectsRequest.setMaxKeys(<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">50<\/span>);\nObjectListing&nbsp;listObjects&nbsp;=&nbsp;amazonS3.listObjects(listObjectsRequest);\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">do<\/span>&nbsp;{\n&nbsp;&nbsp;listResult.addAll(listObjects.getObjectSummaries());\n&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">if<\/span>&nbsp;(listObjects.isTruncated())&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;ListObjectsRequest&nbsp;request&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;ListObjectsRequest();\n&nbsp;&nbsp;&nbsp;&nbsp;request.setBucketName(listObjectsRequest.getBucketName());\n&nbsp;&nbsp;&nbsp;&nbsp;request.setMarker(listObjects.getNextMarker());\n&nbsp;&nbsp;&nbsp;&nbsp;listObjects&nbsp;=&nbsp;&nbsp;amazonS3.listObjects(request);\n&nbsp;&nbsp;}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">else<\/span>&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">break<\/span>;\n&nbsp;&nbsp;}\n}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">while<\/span>&nbsp;(listObjects&nbsp;!=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">null<\/span>);\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">2\u3001\u4f7f\u7528Delimiter\u6a21\u62df\u6587\u4ef6\u5939\u529f\u80fd<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u5047\u8bbe\u6876\u5185\u6709\u5982\u4e0b\u5bf9\u8c61\uff1aa\/1.jpg\u3001a\/2.jpg\u3001a\/b\/1.txt\u3001a\/b\/2.txt\uff0c\u5217\u4e3ea\u6587\u4ef6\u5939\u4e0b\u7684\u6587\u4ef6\u53ca\u5b50\u6587\u4ef6\u5939\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">ListObjectsRequest&nbsp;listObjectsRequest&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;ListObjectsRequest();\nlistObjectsRequest.setBucketName(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>);\nlistObjectsRequest.setDelimiter(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"\/\"<\/span>);\nlistObjectsRequest.setPrefix(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"a\/\"<\/span>);\nObjectListing&nbsp;listing&nbsp;=&nbsp;amazonS3.listObjects(listObjectsRequest);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u904d\u5386\u6240\u6709Object<\/span>\nSystem.out.println(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"Objects:\"<\/span>);\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">for<\/span>&nbsp;(S3ObjectSummary&nbsp;objectSummary&nbsp;:&nbsp;listing.getObjectSummaries())&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(objectSummary.getKey());\n}\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u904d\u5386\u6240\u6709CommonPrefix<\/span>\nSystem.out.println(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"CommonPrefixs:\"<\/span>);\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">for<\/span>&nbsp;(String&nbsp;commonPrefix&nbsp;:&nbsp;listing.getCommonPrefixes())&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(commonPrefix);\n}\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u793a\u4f8b\u4ee3\u7801\u7684\u8f93\u51fa\u5982\u4e0b\uff1a<\/p>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"display: block; font-size: 0.9em; overflow: auto; overflow-scrolling: touch; border-left: 3px solid rgba(0, 0, 0, 0.4); background: rgba(0, 0, 0, 0.05); color: #6a737d; padding-top: 10px; padding-bottom: 10px; padding-left: 20px; padding-right: 10px; margin-bottom: 20px; margin-top: 20px;\">\n<p style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0px; color: black; line-height: 26px;\">Objects:<\/p>\n<p style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0px; color: black; line-height: 26px;\">a\/1.jpg<\/p>\n<p style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0px; color: black; line-height: 26px;\">a\/2.jpg<\/p>\n<p style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0px; color: black; line-height: 26px;\">CommonPrefixs:<\/p>\n<p style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0px; color: black; line-height: 26px;\">a\/b\/<\/p>\n<\/blockquote>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u751f\u6210\u79c1\u6709\u5bf9\u8c61\u53ef\u4e0b\u8f7d\u7684URL\u94fe\u63a5<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">AWS Java SDK\u652f\u6301\u751f\u6210\u53ef\u4e0b\u8f7d\u79c1\u6709\u5bf9\u8c61\u7684URL\u8fde\u63a5\uff0c\u60a8\u53ef\u4ee5\u5c06\u8be5\u94fe\u63a5\u63d0\u4f9b\u7ed9\u7b2c\u4e09\u65b9\u8fdb\u884c\u6587\u4ef6\u4e0b\u8f7d\uff1a<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">GeneratePresignedUrlRequest&nbsp;generatePresignedUrlRequest&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;GeneratePresignedUrlRequest(bucketName,&nbsp;key);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/&nbsp;\u8bbe\u7f6e\u53ef\u4e0b\u8f7dURL\u7684\u8fc7\u671f\u65f6\u95f4\u4e3a1\u5929\u540e<\/span>\ngeneratePresignedUrlRequest.setExpiration(<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;Date(System.currentTimeMillis()+<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">3600<\/span>*<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">1000<\/span>*<span class=\"hljs-number\" style=\"color: #d19a66; line-height: 26px;\">24<\/span>));\nURL&nbsp;url&nbsp;=&nbsp;amazonS3.generatePresignedUrl(generatePresignedUrlRequest);<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u751f\u6210URL<\/span>\nSystem.out.println(url);<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u53ef\u4ee5\u7528\u8fd9\u4e2aurl\u6765\u4e0b\u8f7d\u6587\u4ef6<\/span>\n<\/code><\/pre>\n<h4 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u6587\u4ef6\u4e0a\u4f20\u4e0b\u8f7d\u5de5\u5177\u7c7b TransferManager<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h4>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u524d\u6587\u63d0\u5230\u7684\u662f Java SDK\u63d0\u4f9b\u7684\u57fa\u7840\u63a5\u53e3\uff0c\u4e3a\u65b9\u4fbf\u7528\u6237\u8fdb\u884c\u6587\u4ef6\u4e0a\u4f20\u4e0b\u8f7d\uff0cJava SDK\u63d0\u4f9b\u4e86\u5c01\u88c5\u66f4\u597d\u3001\u4f7f\u7528\u66f4\u65b9\u4fbf\u7684\u5de5\u5177\u7c7b\uff1aTransferManager\u3002<\/p>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">TransferManager\u7684\u521d\u59cb\u5316<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u6ce8\uff1a\u5728 SpringBoot \u9879\u76ee\u4e2d TransferManager \u7684\u521d\u59cb\u5316 \u53c2\u8003\u4e0a\u8ff0 [\u914d\u7f6e\u6a21\u5f0f](#### \u914d\u7f6e\u6a21\u5f0f)<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u5148\u5b9e\u4f8b\u5316\u4e00\u4e2aAmazonS3<\/span>\nString&nbsp;accessKey&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-accesskey\"<\/span>;\nString&nbsp;secretKey&nbsp;=&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-secretKey&nbsp;\"<\/span>;\nCredentials&nbsp;credentials&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;BasicCredentials(accessKey,&nbsp;secretKey);\nAmazonS3&nbsp;amazonS3&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;AmazonS3(credentials);\namazonS3.setEndpoint(endPoint);\n<span class=\"hljs-comment\" style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u7136\u540e\u901a\u8fc7AmazonS3\u5bf9\u8c61\u6765\u521d\u59cb\u5316TransferManager<\/span>\nTransferManager&nbsp;transferManager&nbsp;=&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;TransferManager(amazonS3);\nDownload&nbsp;download&nbsp;=&nbsp;transferManager.download(TestConfig.bucketName,key,<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">new<\/span>&nbsp;File(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"localFilePath\"<\/span>));\n<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">try<\/span>&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;download.waitForCompletion();\n}&nbsp;<span class=\"hljs-keyword\" style=\"color: #c678dd; line-height: 26px;\">catch<\/span>&nbsp;(InterruptedException&nbsp;e)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();\n}\n<\/code><\/pre>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u4f7f\u7528TransferManager\u8fdb\u884c\u6587\u4ef6\u4e0a\u4f20<\/span><span class=\"suffix\" style=\"display: none;\"><\/span><\/h5>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">TransferManager\u4f1a\u6839\u636e\u6587\u4ef6\u5927\u5c0f\uff0c\u9009\u62e9\u662f\u5426\u8fdb\u884c\u5206\u5757\u4e0a\u4f20\u3002\u5f53\u6587\u4ef6\u5c0f\u4e8e\u7b49\u4e8e16M\u65f6\uff0cTransferManager\u4f1a\u81ea\u52a8\u8c03\u7528PutObject\u63a5\u53e3\uff0c\u5426\u5219TransferManager\u4f1a\u81ea\u52a8\u5bf9\u6587\u4ef6\u8fdb\u884c\u5206\u5757\u4e0a\u4f20\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">1\u3001\u4e0a\u4f20\u672c\u5730\u6587\u4ef6\uff1a<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u5982\u679c\u6307\u5b9a\u4e0a\u4f20\u7684\u672c\u5730\u6587\u4ef6\u5927\u4e8e16M\uff0cTransferManager\u4f1a\u81ea\u52a8\u5bf9\u6587\u4ef6\u8fdb\u884c\u5206\u5757\uff0c\u5e76\u53d1\u8c03\u7528\u5206\u5757\u4e0a\u4f20\u63a5\u53e3\u8fdb\u884c\u4e0a\u4f20\uff0c\u5927\u5927\u63d0\u9ad8\u4e0a\u4f20\u6587\u4ef6\u7684\u901f\u5ea6\u3002<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">\/\/\u4e0a\u4f20\u6587\u4ef6\nUpload&nbsp;upload&nbsp;=&nbsp;transferManager.upload(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>,&nbsp;new&nbsp;File(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-file\"<\/span>));\ntry&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;upload.waitForUploadResult();\n}&nbsp;catch&nbsp;(InterruptedException&nbsp;e)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();\n}\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">2\u3001\u6d41\u5f0f\u4e0a\u4f20\uff1a<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528TransferManager\u8fdb\u884c\u6d41\u5f0f\u4e0a\u4f20\uff0c\u4f46\u662f\u76f8\u6bd4\u672c\u5730\u6587\u4ef6\u4e0a\u4f20\uff0c\u6d41\u5f0f\u4e0a\u4f20\u65e0\u6cd5\u505a\u5230\u591a\u4e2a\u5206\u5757\u5e76\u53d1\u4e0a\u4f20\uff0c\u53ea\u80fd\u4e00\u4e2a\u5206\u5757\u4e00\u4e2a\u5206\u5757\u987a\u5e8f\u4e0a\u4f20\u3002<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">\/\/\u6d41\u5f0f\u4e0a\u4f20\u6587\u4ef6\nObjectMetadata&nbsp;objectMetadata&nbsp;=&nbsp;new&nbsp;ObjectMetadata();\nobjectMetadata.setContentLength(file.length());\nUpload&nbsp;upload&nbsp;=&nbsp;transferManager.upload(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>,&nbsp;inputStream,&nbsp;objectMetadata);\nUploadResult&nbsp;&nbsp;result&nbsp;=&nbsp;upload.waitForUploadResult();\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">3\u3001\u4e0a\u4f20\u76ee\u5f55<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">\u60a8\u53ef\u4ee5\u4f7f\u7528TransferManager\u5c06\u67d0\u4e2a\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u5168\u90e8\u4e0a\u4f20\u5230NOS,\u5bf9\u8c61\u540d\u5373\u6587\u4ef6\u540d<\/p>\n<ul data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;\">3.1 \u4e0d\u652f\u6301\u591a\u7ea7\u76ee\u5f55<\/section>\n<\/li>\n<\/ul>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">MultipleFileUpload&nbsp;result&nbsp;=&nbsp;transferManager.uploadDirectory(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-buckename\"<\/span>,&nbsp;null,&nbsp;new&nbsp;File(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"dirPath\"<\/span>),&nbsp;<span class=\"hljs-literal\" style=\"color: #56b6c2; line-height: 26px;\">false<\/span>);\nresult.waitForCompletion();\n<\/code><\/pre>\n<ul data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;\">3.2 \u652f\u6301\u591a\u7ea7\u76ee\u5f55\uff0c\u4f1a\u9012\u5f52\u7684\u4e0a\u4f20\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6<\/section>\n<\/li>\n<\/ul>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">MultipleFileUpload&nbsp;result&nbsp;=&nbsp;transferManager.uploadDirectory(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-buckename\"<\/span>,&nbsp;null,&nbsp;new&nbsp;File(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"dirPath\"<\/span>),&nbsp;<span class=\"hljs-literal\" style=\"color: #56b6c2; line-height: 26px;\">true<\/span>);\nresult.waitForCompletion();\n<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">4\u3001\u4e0b\u8f7d\u6587\u4ef6<\/p>\n<pre class=\"custom\" data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block; background: url(https:\/\/my-wechat.mdnice.com\/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;\"><\/span><code class=\"hljs\" style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">File&nbsp;file&nbsp;=&nbsp;new&nbsp;&nbsp;File(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-destFile\"<\/span>);\nDownload&nbsp;download&nbsp;=&nbsp;transferManager.download(<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-bucketname\"<\/span>,&nbsp;<span class=\"hljs-string\" style=\"color: #98c379; line-height: 26px;\">\"your-objectname\"<\/span>,&nbsp;file);\ndownload.waitForCompletion();\n<\/code><\/pre>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 22px;\"><span class=\"prefix\" style=\"display: none;\"><\/span><span class=\"content\">\u53c2\u8003\u8d44\u6599<\/span><span class=\"suffix\"><\/span><\/h2>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;\">[1]  <a href=\"https:\/\/www.163yun.com\/help\/documents\/105044625933389824\" style=\"text-decoration: none; color: #1e6bb8; word-wrap: break-word; font-weight: bold; border-bottom: 1px solid #1e6bb8;\"><em style=\"font-style: italic; color: black;\">\u7f51\u6613\u6570\u5e06S3 Java SDK \u624b\u518c<\/em><\/a><\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883\u51c6\u5907 \u5f00\u59cb\u4f7f\u7528 1. \u5f15\u5165\u4f9d\u8d56 2. \u521d\u59cb\u5316 3. \u4f9d\u8d56\u6ce8\u5165 4. \u6587\u4ef6\u64cd\u4f5c \u53c2\u8003\u8d44\u6599 \u73af\u5883\u51c6\u5907 Java &hellip; <a href=\"https:\/\/www.changxuan.top\/?p=963\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,54],"tags":[85,75],"class_list":["post-963","post","type-post","status-publish","format-standard","hentry","category-tech","category-54","tag-amazons3","tag-springboot"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b - \u5e38\u8f69<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.changxuan.top\/?p=963\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b - \u5e38\u8f69\" \/>\n<meta property=\"og:description\" content=\"\u73af\u5883\u51c6\u5907 \u5f00\u59cb\u4f7f\u7528 1. \u5f15\u5165\u4f9d\u8d56 2. \u521d\u59cb\u5316 3. \u4f9d\u8d56\u6ce8\u5165 4. \u6587\u4ef6\u64cd\u4f5c \u53c2\u8003\u8d44\u6599 \u73af\u5883\u51c6\u5907 Java &hellip; \u7ee7\u7eed\u9605\u8bfbSpring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.changxuan.top\/?p=963\" \/>\n<meta property=\"og:site_name\" content=\"\u5e38\u8f69\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-11T03:27:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-10-12T12:30:19+00:00\" \/>\n<meta name=\"author\" content=\"\u5e38\u8f69\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5e38\u8f69\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=963#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=963\"},\"author\":{\"name\":\"\u5e38\u8f69\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#\\\/schema\\\/person\\\/08c8f0af44536928094dc1b4f88da3bd\"},\"headline\":\"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b\",\"datePublished\":\"2020-08-11T03:27:41+00:00\",\"dateModified\":\"2020-10-12T12:30:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=963\"},\"wordCount\":141,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#\\\/schema\\\/person\\\/08c8f0af44536928094dc1b4f88da3bd\"},\"keywords\":[\"AmazonS3\",\"SpringBoot\"],\"articleSection\":[\"\u6280\u672f\",\"\u6559\u7a0b\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.changxuan.top\\\/?p=963#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=963\",\"url\":\"https:\\\/\\\/www.changxuan.top\\\/?p=963\",\"name\":\"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b - \u5e38\u8f69\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#website\"},\"datePublished\":\"2020-08-11T03:27:41+00:00\",\"dateModified\":\"2020-10-12T12:30:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=963#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.changxuan.top\\\/?p=963\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/?p=963#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/www.changxuan.top\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#website\",\"url\":\"https:\\\/\\\/www.changxuan.top\\\/\",\"name\":\"\u5e38\u8f69\",\"description\":\"\u95fb\u9053\u6709\u5148\u540e\uff0c\u672f\u4e1a\u6709\u4e13\u653b-\u4e00\u4e8c\u4e09\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#\\\/schema\\\/person\\\/08c8f0af44536928094dc1b4f88da3bd\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.changxuan.top\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/#\\\/schema\\\/person\\\/08c8f0af44536928094dc1b4f88da3bd\",\"name\":\"\u5e38\u8f69\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/IMG_008520200606-095631.jpg\",\"url\":\"https:\\\/\\\/www.changxuan.top\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/IMG_008520200606-095631.jpg\",\"contentUrl\":\"https:\\\/\\\/www.changxuan.top\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/IMG_008520200606-095631.jpg\",\"width\":960,\"height\":960,\"caption\":\"\u5e38\u8f69\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.changxuan.top\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/IMG_008520200606-095631.jpg\"},\"description\":\"\u603b\u8981\u505a\u70b9\u4ec0\u4e48\u5427\uff01\",\"sameAs\":[\"https:\\\/\\\/www.changxuan.top\"],\"url\":\"https:\\\/\\\/www.changxuan.top\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b - \u5e38\u8f69","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.changxuan.top\/?p=963","og_locale":"zh_CN","og_type":"article","og_title":"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b - \u5e38\u8f69","og_description":"\u73af\u5883\u51c6\u5907 \u5f00\u59cb\u4f7f\u7528 1. \u5f15\u5165\u4f9d\u8d56 2. \u521d\u59cb\u5316 3. \u4f9d\u8d56\u6ce8\u5165 4. \u6587\u4ef6\u64cd\u4f5c \u53c2\u8003\u8d44\u6599 \u73af\u5883\u51c6\u5907 Java &hellip; \u7ee7\u7eed\u9605\u8bfbSpring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b","og_url":"https:\/\/www.changxuan.top\/?p=963","og_site_name":"\u5e38\u8f69","article_published_time":"2020-08-11T03:27:41+00:00","article_modified_time":"2020-10-12T12:30:19+00:00","author":"\u5e38\u8f69","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5e38\u8f69","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.changxuan.top\/?p=963#article","isPartOf":{"@id":"https:\/\/www.changxuan.top\/?p=963"},"author":{"name":"\u5e38\u8f69","@id":"https:\/\/www.changxuan.top\/#\/schema\/person\/08c8f0af44536928094dc1b4f88da3bd"},"headline":"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b","datePublished":"2020-08-11T03:27:41+00:00","dateModified":"2020-10-12T12:30:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.changxuan.top\/?p=963"},"wordCount":141,"commentCount":0,"publisher":{"@id":"https:\/\/www.changxuan.top\/#\/schema\/person\/08c8f0af44536928094dc1b4f88da3bd"},"keywords":["AmazonS3","SpringBoot"],"articleSection":["\u6280\u672f","\u6559\u7a0b"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.changxuan.top\/?p=963#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.changxuan.top\/?p=963","url":"https:\/\/www.changxuan.top\/?p=963","name":"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b - \u5e38\u8f69","isPartOf":{"@id":"https:\/\/www.changxuan.top\/#website"},"datePublished":"2020-08-11T03:27:41+00:00","dateModified":"2020-10-12T12:30:19+00:00","breadcrumb":{"@id":"https:\/\/www.changxuan.top\/?p=963#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.changxuan.top\/?p=963"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.changxuan.top\/?p=963#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.changxuan.top\/"},{"@type":"ListItem","position":2,"name":"Spring Boot \u96c6\u6210 AmazonS3 \u5b58\u50a8\u670d\u52a1\u6559\u7a0b"}]},{"@type":"WebSite","@id":"https:\/\/www.changxuan.top\/#website","url":"https:\/\/www.changxuan.top\/","name":"\u5e38\u8f69","description":"\u95fb\u9053\u6709\u5148\u540e\uff0c\u672f\u4e1a\u6709\u4e13\u653b-\u4e00\u4e8c\u4e09","publisher":{"@id":"https:\/\/www.changxuan.top\/#\/schema\/person\/08c8f0af44536928094dc1b4f88da3bd"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.changxuan.top\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.changxuan.top\/#\/schema\/person\/08c8f0af44536928094dc1b4f88da3bd","name":"\u5e38\u8f69","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.changxuan.top\/wp-content\/uploads\/2021\/04\/IMG_008520200606-095631.jpg","url":"https:\/\/www.changxuan.top\/wp-content\/uploads\/2021\/04\/IMG_008520200606-095631.jpg","contentUrl":"https:\/\/www.changxuan.top\/wp-content\/uploads\/2021\/04\/IMG_008520200606-095631.jpg","width":960,"height":960,"caption":"\u5e38\u8f69"},"logo":{"@id":"https:\/\/www.changxuan.top\/wp-content\/uploads\/2021\/04\/IMG_008520200606-095631.jpg"},"description":"\u603b\u8981\u505a\u70b9\u4ec0\u4e48\u5427\uff01","sameAs":["https:\/\/www.changxuan.top"],"url":"https:\/\/www.changxuan.top\/?author=1"}]}},"views":4657,"_links":{"self":[{"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/posts\/963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=963"}],"version-history":[{"count":6,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/posts\/963\/revisions"}],"predecessor-version":[{"id":982,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=\/wp\/v2\/posts\/963\/revisions\/982"}],"wp:attachment":[{"href":"https:\/\/www.changxuan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.changxuan.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}