我正在尝试将一个大文件上载到使用令牌的服务器,令牌将在10分钟后过期,因此如果我上载一个小文件,它将正常工作,因此如果文件比我大,我将遇到一些问题,并将尝试在访问被拒绝的情况下永久上载
所以我需要刷新
基本凭证
AWSStaticCredentialsProvider软件
值得一提的是,我们使用本地服务器(而不是amazon云)提供令牌,为了方便起见,我们使用amazon的代码。
public void uploadMultipart(File file) throws Exception {
//this method will give you a initial token for a given user,
//than calculates when a new token is needed and will refresh it just when necessary
String token = getUsetToken();
String existingBucketName = myTenant.toLowerCase() + ".package.upload";
String endPoint = urlAPI + "s3/buckets/";
String strSize = FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(file));
System.out.println("File size: " + strSize);
AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(endPoint, null);