亚马逊S3的使用

一、下载s3browser客户端

1、进入下载页面进行下载

下载亚马逊S3客户端地址

2、使用客户端进行连接公司亚马逊服务

 连接成功之后的界面如下:

可以一目了然的看到上传之后的文件和文件目录存储结构。

二、亚马逊 AmazonS3的使用

1、引入pom依赖

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-s3</artifactId>
    <version>1.11.792</version>
</dependency>

 2、application.properties添加配置

#-------------------- S3 start -------------------
# http or https
amazonaws.s3.protocol = http
# host:port       (test1.endpoint=192.168.66.224:7480)
amazonaws.s3.endpoint = 192.168.66.224:7480
# accessKey    (test1.accessKey=123456)
amazonaws.s3.accessKey = 123456
# secretKey    (test1.secretKey=123456)
amazonaws.s3.secretKey = 123456
# maxConnections   (def=50)
amazonaws.s3.maxConnections = 50
# connectionTimeout   (def=10000)
amazonaws.s3.connectionTimeout = 10000
# socketTimeout   (def=50000)
amazonaws.s3.socketTimeout = 50000
# useGzip   (def=false)
amazonaws.s3.useGzip = false
# bucketName   (def=icollect)
amazonaws.s3.bucketName = icollect
#amazonaws.s3.template.key (def=template.xlsx)
amazonaws.s3.templateKey = template
#amazonaws.s3.template.path (def=template.xlsx)
amazonaws.s3.templatePath = D://template
#-------------------- S3 end -------------------

3 、添加配置类AmazonS3Properties

import com.amazonaws.ClientConfiguration;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author 痞子磊
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
@ConfigurationProperties(prefix = "amazonaws.s3")
@Configuration
public class AmazonS3Properties {
    //private String regionName;
    private String endpoint;
    priv
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

莱恩大数据

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值