文件上传经过本地服务:错误分析

1.公共服务导入依赖

 		<dependency> <!--不加版本号会有问题-->
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alicloud-oss</artifactId>
            <version>2.1.0.RELEASE</version>
            <type>pom</type>
        </dependency>

2.需要文件上传的服务配置

spring:
  cloud:
    alicloud:
      access-key: xx
      secret-key: xx
      oss:
        endpoint: oss-cn-beijing.aliyuncs.com

3.测试类测试

 	@Autowired
    OSSClient ossClient;
    @Test
    void testUpload(){
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream("C:\\Users\\28417\\Desktop\\上传.jpg");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。
        ossClient.putObject("wlun-bucket", "上传1.jpg", inputStream);

        // 关闭OSSClient。
        ossClient.shutdown();
        System.out.println("上传完成!!!");
    }

错误:

com.aliyun.oss.OSSException: The difference between the request time and the current time is too large.
双系统,所以开机之后时间存在问题,跟oss服务器时间间隔超过15分钟,更新系统时间解决问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值