Sunday, 30 January 2022

App crash on firestick 2nd gen when getting presigned URL

Gradle

implementation platform('software.amazon.awssdk:bom:2.17.119')
implementation 'software.amazon.awssdk:s3'

Code Used To get Presigned Url

public static URL getPresignedUrl(String bucketName, String keyName ) {
    PresignedGetObjectRequest presignedGetObjectRequest = null;
    try {
        AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create
                (AwsBasicCredentials.create(Access Key, Secret Key));


        S3Presigner preSigner = S3Presigner.builder()
                .credentialsProvider(credentialsProvider)
                .region(Region.US_WEST_2).build();
        GetObjectRequest getObjectRequest =
                GetObjectRequest.builder()
                        .bucket(bucketName)
                        .key(keyName)
                        .build();

        GetObjectPresignRequest getObjectPresignRequest = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            getObjectPresignRequest = GetObjectPresignRequest.builder()
                    .signatureDuration(Duration.ofDays(1))
                    .getObjectRequest(getObjectRequest)
                    .build();
        }

        // Generate the presigned request
         presignedGetObjectRequest =
                 preSigner.presignGetObject(getObjectPresignRequest);
    } catch (Exception e) {
        e.getStackTrace();
    }
    return  presignedGetObjectRequest.url();
}

App working fine if the fire OS version is greater than or equal 7.x.x Crashes on fire OS version 5.x.x

Crashing on the line S3Presigner preSigner = S3Presigner.builder()

Crash Log

Need help



from App crash on firestick 2nd gen when getting presigned URL

No comments:

Post a Comment