相关文章推荐
重情义的自行车  ·  在AWS ...·  5 小时前    · 
被表白的眼镜  ·  SSO CAS - 简书·  9 月前    · 
耍酷的枕头  ·  python - ...·  1 年前    · 
温暖的松树  ·  python - slide ...·  1 年前    · 

使用aws s3直接加载图片到imageview,而不需要下载到android的本地存储,来自digital ocean

0 人关注

所以,我试图用s3证书和预设的url从数字云空间获取图片,这样我就可以在glide中使用该url来下载了。

AmazonS3 s3Client = AmazonS3ClientBuilder.standard() .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://sgp1.digitaloceanspaces.com", "sgp1")) .withCredentials(new AWSStaticCredentialsProvider( new BasicAWSCredentials(key, secret)).build()。

    java.util.Date expiration = new java.util.Date();
    long expTimeMillis = expiration.getTime();
    expTimeMillis += 1000 * 60 * 30;
    expiration.setTime(expTimeMillis);
    GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest("\n" +
            "sample",
            "my.png").withMethod(HttpMethod.GET)
            .withExpiration(expiration);
    URL url = s3Client.generatePresignedUrl(generatePresignedUrlRequest);

与实施平台('com.amazonaws:aws-java-sdk-bom:1.11.825') 实现'com.amazonaws:aws-java-sdk-s3'。 这些依赖关系

它给出了以下错误 进程:com.sunny.flat_belly_12days,PID:15403 java.lang.NoClassDefFoundError。解析失败。Ljavax/management/MBeanServerFactory。 at com.amazonaws.jmx.MBeans.getMBeanServer(MBeans.java:111)

而如果我使用 - AmazonS3Client s3; BasicAWSCredentials credentials。

String key = "xxxxx"; //SpacesKey
String secret = "yyyyyyyyy"; //Spaces Secret key
credentials = new BasicAWSCredentials(key, secret);
s3 = new AmazonS3Client(credentials);
s3.setEndpoint("https://RegionName.digitaloceanspaces.com"); //endpoint
Date expires = new Date (new Date().getTime() + 1000 * 60); // 1 minute to expire
GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, objectKey);  //generating the signatured url