diff --git a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/AWSS3StoragePlugin.java b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/AWSS3StoragePlugin.java index 26403ccb7..01fde9ba4 100644 --- a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/AWSS3StoragePlugin.java +++ b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/AWSS3StoragePlugin.java @@ -362,13 +362,8 @@ public StorageGetUrlOperation getUrl( AWSS3StorageService storageService = defaultStorageService; try { storageService = getStorageService(options.getBucket()); - } catch (InvalidStorageBucketException exception) { - onError.accept( - new StorageException( - "Unable to find bucket from name in Amplify Outputs.", - exception, - "Ensure the bucket name used is available in Amplify Outputs.") - ); + } catch (StorageException exception) { + onError.accept(exception); } AWSS3StorageGetPresignedUrlOperation operation = @@ -409,13 +404,8 @@ public StorageGetUrlOperation getUrl( AWSS3StorageService storageService = defaultStorageService; try { storageService = getStorageService(options.getBucket()); - } catch (InvalidStorageBucketException exception) { - onError.accept( - new StorageException( - "Unable to find bucket from name in Amplify Outputs.", - exception, - "Ensure the bucket name used is available in Amplify Outputs.") - ); + } catch (StorageException exception) { + onError.accept(exception); } AWSS3StoragePathGetPresignedUrlOperation operation = @@ -505,8 +495,15 @@ public StorageDownloadFileOperation downloadFile( useAccelerateEndpoint ); + AWSS3StorageService storageService = defaultStorageService; + try { + storageService = getStorageService(options.getBucket()); + } catch (StorageException exception) { + onError.accept(exception); + } + AWSS3StorageDownloadFileOperation operation = new AWSS3StorageDownloadFileOperation( - defaultStorageService, + storageService, executorService, authCredentialsProvider, request, @@ -540,9 +537,16 @@ public StorageDownloadFileOperation downloadFile( useAccelerateEndpoint ); + AWSS3StorageService storageService = defaultStorageService; + try { + storageService = getStorageService(options.getBucket()); + } catch (StorageException exception) { + onError.accept(exception); + } + AWSS3StoragePathDownloadFileOperation operation = new AWSS3StoragePathDownloadFileOperation( request, - defaultStorageService, + storageService, executorService, authCredentialsProvider, onProgress, @@ -632,8 +636,15 @@ public StorageUploadFileOperation uploadFile( useAccelerateEndpoint ); + AWSS3StorageService storageService = defaultStorageService; + try { + storageService = getStorageService(options.getBucket()); + } catch (StorageException exception) { + onError.accept(exception); + } + AWSS3StorageUploadFileOperation operation = new AWSS3StorageUploadFileOperation( - defaultStorageService, + storageService, executorService, authCredentialsProvider, request, @@ -670,9 +681,16 @@ public StorageUploadFileOperation uploadFile( useAccelerateEndpoint ); + AWSS3StorageService storageService = defaultStorageService; + try { + storageService = getStorageService(options.getBucket()); + } catch (StorageException exception) { + onError.accept(exception); + } + AWSS3StoragePathUploadFileOperation operation = new AWSS3StoragePathUploadFileOperation( request, - defaultStorageService, + storageService, executorService, authCredentialsProvider, onProgress, @@ -760,8 +778,15 @@ public StorageUploadInputStreamOperation uploadInputStream( useAccelerateEndpoint ); + AWSS3StorageService storageService = defaultStorageService; + try { + storageService = getStorageService(options.getBucket()); + } catch (StorageException exception) { + onError.accept(exception); + } + AWSS3StorageUploadInputStreamOperation operation = new AWSS3StorageUploadInputStreamOperation( - defaultStorageService, + storageService, executorService, authCredentialsProvider, awsS3StoragePluginConfiguration, @@ -798,10 +823,17 @@ public StorageUploadInputStreamOperation uploadInputStream( useAccelerateEndpoint ); + AWSS3StorageService storageService = defaultStorageService; + try { + storageService = getStorageService(options.getBucket()); + } catch (StorageException exception) { + onError.accept(exception); + } + AWSS3StoragePathUploadInputStreamOperation operation = new AWSS3StoragePathUploadInputStreamOperation( request, - defaultStorageService, + storageService, executorService, authCredentialsProvider, onProgress, @@ -851,9 +883,16 @@ public StorageRemoveOperation remove( options.getTargetIdentityId() ); + AWSS3StorageService storageService = defaultStorageService; + try { + storageService = getStorageService(options.getBucket()); + } catch (StorageException exception) { + onError.accept(exception); + } + AWSS3StorageRemoveOperation operation = new AWSS3StorageRemoveOperation( - defaultStorageService, + storageService, executorService, authCredentialsProvider, request, @@ -876,9 +915,16 @@ public StorageRemoveOperation remove( ) { AWSS3StoragePathRemoveRequest request = new AWSS3StoragePathRemoveRequest(path); + AWSS3StorageService storageService = defaultStorageService; + try { + storageService = getStorageService(options.getBucket()); + } catch (StorageException exception) { + onError.accept(exception); + } + AWSS3StoragePathRemoveOperation operation = new AWSS3StoragePathRemoveOperation( - defaultStorageService, + storageService, executorService, authCredentialsProvider, request, @@ -1053,7 +1099,7 @@ public StorageListOperation list( @SuppressLint("UnsafeOptInUsageError") @VisibleForTesting @NonNull - AWSS3StorageService getStorageService(@Nullable StorageBucket bucket) throws InvalidStorageBucketException { + AWSS3StorageService getStorageService(@Nullable StorageBucket bucket) throws StorageException { if (bucket == null) { return defaultStorageService; } @@ -1061,7 +1107,10 @@ AWSS3StorageService getStorageService(@Nullable StorageBucket bucket) throws Inv if (bucket instanceof OutputsStorageBucket) { AWSS3StorageService service = getAWSS3StorageService((OutputsStorageBucket) bucket); if (service == null) { - throw new InvalidStorageBucketException(); + throw new StorageException( + "Unable to find bucket from name in Amplify Outputs.", + new InvalidStorageBucketException(), + "Ensure the bucket name used is available in Amplify Outputs."); } else { return service; } diff --git a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageDownloadFileOptions.java b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageDownloadFileOptions.java index e9d7f024e..416df3001 100644 --- a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageDownloadFileOptions.java +++ b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageDownloadFileOptions.java @@ -57,9 +57,10 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final AWSS3StorageDownloadFileOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()) - .setUseAccelerateEndpoint(options.useAccelerateEndpoint()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .setUseAccelerateEndpoint(options.useAccelerateEndpoint()) + .bucket(options.getBucket()); } /** @@ -90,7 +91,8 @@ public boolean equals(Object obj) { } else { AWSS3StorageDownloadFileOptions that = (AWSS3StorageDownloadFileOptions) obj; return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && - ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()); + ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -99,7 +101,8 @@ public boolean equals(Object obj) { public int hashCode() { return ObjectsCompat.hash( getAccessLevel(), - getTargetIdentityId() + getTargetIdentityId(), + getBucket() ); } @@ -111,6 +114,7 @@ public String toString() { "accessLevel=" + getAccessLevel() + ", targetIdentityId=" + getTargetIdentityId() + ", useAccelerationMode=" + useAccelerateEndpoint() + + ", bucket=" + getBucket() + '}'; } diff --git a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageListOptions.java b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageListOptions.java index d6335b85d..b314ba292 100644 --- a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageListOptions.java +++ b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageListOptions.java @@ -55,8 +55,9 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final AWSS3StorageListOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .bucket(options.getBucket()); } /** @@ -78,7 +79,8 @@ public boolean equals(Object obj) { } else { AWSS3StorageListOptions that = (AWSS3StorageListOptions) obj; return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && - ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()); + ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -87,7 +89,8 @@ public boolean equals(Object obj) { public int hashCode() { return ObjectsCompat.hash( getAccessLevel(), - getTargetIdentityId() + getTargetIdentityId(), + getBucket() ); } @@ -98,6 +101,7 @@ public String toString() { return "AWSS3StorageListOptions {" + "accessLevel=" + getAccessLevel() + ", targetIdentityId=" + getTargetIdentityId() + + ", bucket=" + getBucket() + '}'; } diff --git a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageRemoveOptions.java b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageRemoveOptions.java index 244abe1f8..b74f08b75 100644 --- a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageRemoveOptions.java +++ b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageRemoveOptions.java @@ -56,8 +56,9 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final AWSS3StorageRemoveOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .bucket(options.getBucket()); } /** @@ -79,7 +80,8 @@ public boolean equals(Object obj) { } else { AWSS3StorageRemoveOptions that = (AWSS3StorageRemoveOptions) obj; return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && - ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()); + ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -88,7 +90,8 @@ public boolean equals(Object obj) { public int hashCode() { return ObjectsCompat.hash( getAccessLevel(), - getTargetIdentityId() + getTargetIdentityId(), + getBucket() ); } @@ -99,6 +102,7 @@ public String toString() { return "AWSS3StorageRemoveOptions {" + "accessLevel=" + getAccessLevel() + ", targetIdentityId=" + getTargetIdentityId() + + ", bucket=" + getBucket() + '}'; } diff --git a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageUploadFileOptions.java b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageUploadFileOptions.java index 39dfdcaf4..00ce8ff61 100644 --- a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageUploadFileOptions.java +++ b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageUploadFileOptions.java @@ -71,11 +71,12 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final AWSS3StorageUploadFileOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()) - .contentType(options.getContentType()) - .serverSideEncryption(options.getServerSideEncryption()) - .metadata(options.getMetadata()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .contentType(options.getContentType()) + .serverSideEncryption(options.getServerSideEncryption()) + .metadata(options.getMetadata()) + .bucket(options.getBucket()); } /** @@ -109,7 +110,8 @@ public boolean equals(Object obj) { ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && ObjectsCompat.equals(getContentType(), that.getContentType()) && ObjectsCompat.equals(getServerSideEncryption(), that.getServerSideEncryption()) && - ObjectsCompat.equals(getMetadata(), that.getMetadata()); + ObjectsCompat.equals(getMetadata(), that.getMetadata()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -121,7 +123,8 @@ public int hashCode() { getTargetIdentityId(), getContentType(), getServerSideEncryption(), - getMetadata() + getMetadata(), + getBucket() ); } @@ -135,6 +138,7 @@ public String toString() { ", contentType=" + getContentType() + ", serverSideEncryption=" + getServerSideEncryption().getName() + ", metadata=" + getMetadata() + + ", bucket=" + getBucket() + '}'; } diff --git a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageUploadInputStreamOptions.java b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageUploadInputStreamOptions.java index e14296a2c..3bf4f6a36 100644 --- a/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageUploadInputStreamOptions.java +++ b/aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/options/AWSS3StorageUploadInputStreamOptions.java @@ -75,7 +75,8 @@ public static Builder from(@NonNull final AWSS3StorageUploadInputStreamOptions o .targetIdentityId(options.getTargetIdentityId()) .contentType(options.getContentType()) .serverSideEncryption(options.getServerSideEncryption()) - .metadata(options.getMetadata()); + .metadata(options.getMetadata()) + .bucket(options.getBucket()); } /** @@ -109,7 +110,8 @@ public boolean equals(Object obj) { ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && ObjectsCompat.equals(getContentType(), that.getContentType()) && ObjectsCompat.equals(getServerSideEncryption(), that.getServerSideEncryption()) && - ObjectsCompat.equals(getMetadata(), that.getMetadata()); + ObjectsCompat.equals(getMetadata(), that.getMetadata()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -121,7 +123,8 @@ public int hashCode() { getTargetIdentityId(), getContentType(), getServerSideEncryption(), - getMetadata() + getMetadata(), + getBucket() ); } @@ -135,6 +138,7 @@ public String toString() { ", contentType=" + getContentType() + ", serverSideEncryption=" + getServerSideEncryption().getName() + ", metadata=" + getMetadata() + + ", bucket=" + getBucket() + '}'; } diff --git a/aws-storage-s3/src/test/java/com/amplifyframework/storage/s3/AWSS3StoragePluginTest.kt b/aws-storage-s3/src/test/java/com/amplifyframework/storage/s3/AWSS3StoragePluginTest.kt index e5e13cfe4..a13158f1b 100644 --- a/aws-storage-s3/src/test/java/com/amplifyframework/storage/s3/AWSS3StoragePluginTest.kt +++ b/aws-storage-s3/src/test/java/com/amplifyframework/storage/s3/AWSS3StoragePluginTest.kt @@ -24,6 +24,7 @@ import com.amplifyframework.storage.s3.service.StorageService import com.amplifyframework.testutils.configuration.amplifyOutputsData import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.shouldNotBe +import io.kotest.matchers.throwable.shouldHaveCauseOfType import io.mockk.every import io.mockk.mockk import io.mockk.verify @@ -129,7 +130,7 @@ class AWSS3StoragePluginTest { } @Test - fun `getStorageService throws InvalidStorageBucketException`() { + fun `getStorageService throws StorageException`() { val data = amplifyOutputsData { storage { awsRegion = "test-region" @@ -144,8 +145,9 @@ class AWSS3StoragePluginTest { plugin.configure(data, mockk()) val bucket = StorageBucket.fromOutputs("myBucket") - shouldThrow { + val exception = shouldThrow { plugin.getStorageService(bucket) } + exception.shouldHaveCauseOfType() } } diff --git a/core/src/main/java/com/amplifyframework/storage/options/StorageDownloadFileOptions.java b/core/src/main/java/com/amplifyframework/storage/options/StorageDownloadFileOptions.java index 846991f96..18e8b22a4 100644 --- a/core/src/main/java/com/amplifyframework/storage/options/StorageDownloadFileOptions.java +++ b/core/src/main/java/com/amplifyframework/storage/options/StorageDownloadFileOptions.java @@ -30,7 +30,7 @@ public class StorageDownloadFileOptions extends StorageOptions { */ @SuppressWarnings("deprecation") protected StorageDownloadFileOptions(final Builder builder) { - super(builder.getAccessLevel(), builder.getTargetIdentityId()); + super(builder.getAccessLevel(), builder.getTargetIdentityId(), builder.getBucket()); } /** @@ -59,8 +59,9 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final StorageDownloadFileOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .bucket(options.getBucket()); } /** @@ -85,7 +86,8 @@ public boolean equals(Object obj) { } else { StorageDownloadFileOptions that = (StorageDownloadFileOptions) obj; return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && - ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()); + ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -97,7 +99,8 @@ public boolean equals(Object obj) { public int hashCode() { return ObjectsCompat.hash( getAccessLevel(), - getTargetIdentityId() + getTargetIdentityId(), + getBucket() ); } @@ -109,9 +112,10 @@ public int hashCode() { @SuppressWarnings("deprecation") public String toString() { return "StorageDownloadFileOptions {" + - "accessLevel=" + getAccessLevel() + - ", targetIdentityId=" + getTargetIdentityId() + - '}'; + "accessLevel=" + getAccessLevel() + + ", targetIdentityId=" + getTargetIdentityId() + + ", bucket=" + getBucket() + + '}'; } /** diff --git a/core/src/main/java/com/amplifyframework/storage/options/StorageListOptions.java b/core/src/main/java/com/amplifyframework/storage/options/StorageListOptions.java index 966704e5c..ebd9ae733 100644 --- a/core/src/main/java/com/amplifyframework/storage/options/StorageListOptions.java +++ b/core/src/main/java/com/amplifyframework/storage/options/StorageListOptions.java @@ -31,7 +31,7 @@ public class StorageListOptions extends StorageOptions { */ @SuppressWarnings("deprecation") protected StorageListOptions(final Builder builder) { - super(builder.getAccessLevel(), builder.getTargetIdentityId()); + super(builder.getAccessLevel(), builder.getTargetIdentityId(), builder.getBucket()); } /** @@ -58,8 +58,9 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final StorageListOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .bucket(options.getBucket()); } /** @@ -85,7 +86,8 @@ public boolean equals(Object obj) { } else { StorageListOptions that = (StorageListOptions) obj; return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && - ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()); + ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -97,7 +99,8 @@ public boolean equals(Object obj) { public int hashCode() { return ObjectsCompat.hash( getAccessLevel(), - getTargetIdentityId() + getTargetIdentityId(), + getBucket() ); } @@ -111,6 +114,7 @@ public String toString() { return "StorageListOptions {" + "accessLevel=" + getAccessLevel() + ", targetIdentityId=" + getTargetIdentityId() + + ", bucket=" + getBucket() + '}'; } diff --git a/core/src/main/java/com/amplifyframework/storage/options/StoragePagedListOptions.java b/core/src/main/java/com/amplifyframework/storage/options/StoragePagedListOptions.java index 515f92f25..560997816 100644 --- a/core/src/main/java/com/amplifyframework/storage/options/StoragePagedListOptions.java +++ b/core/src/main/java/com/amplifyframework/storage/options/StoragePagedListOptions.java @@ -33,7 +33,7 @@ public class StoragePagedListOptions extends StorageOptions { */ @SuppressWarnings("deprecation") protected StoragePagedListOptions(Builder builder) { - super(builder.getAccessLevel(), builder.getTargetIdentityId()); + super(builder.getAccessLevel(), builder.getTargetIdentityId(), builder.getBucket()); pageSize = builder.pageSize; nextToken = builder.nextToken; subpathStrategy = builder.subpathStrategy; diff --git a/core/src/main/java/com/amplifyframework/storage/options/StorageRemoveOptions.java b/core/src/main/java/com/amplifyframework/storage/options/StorageRemoveOptions.java index 24c3adc7a..f2f9ef171 100644 --- a/core/src/main/java/com/amplifyframework/storage/options/StorageRemoveOptions.java +++ b/core/src/main/java/com/amplifyframework/storage/options/StorageRemoveOptions.java @@ -31,7 +31,7 @@ public class StorageRemoveOptions extends StorageOptions { */ @SuppressWarnings("deprecation") protected StorageRemoveOptions(final Builder builder) { - super(builder.getAccessLevel(), builder.getTargetIdentityId()); + super(builder.getAccessLevel(), builder.getTargetIdentityId(), builder.getBucket()); } /** @@ -60,8 +60,9 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final StorageRemoveOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .bucket(options.getBucket()); } /** @@ -86,7 +87,8 @@ public boolean equals(Object obj) { } else { StorageRemoveOptions that = (StorageRemoveOptions) obj; return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && - ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()); + ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -98,7 +100,8 @@ public boolean equals(Object obj) { public int hashCode() { return ObjectsCompat.hash( getAccessLevel(), - getTargetIdentityId() + getTargetIdentityId(), + getBucket() ); } @@ -112,6 +115,7 @@ public String toString() { return "StorageRemoveOptions {" + "accessLevel=" + getAccessLevel() + ", targetIdentityId=" + getTargetIdentityId() + + ", bucket=" + getBucket() + '}'; } diff --git a/core/src/main/java/com/amplifyframework/storage/options/StorageUploadFileOptions.java b/core/src/main/java/com/amplifyframework/storage/options/StorageUploadFileOptions.java index 18dbcca58..1a17ab3cc 100644 --- a/core/src/main/java/com/amplifyframework/storage/options/StorageUploadFileOptions.java +++ b/core/src/main/java/com/amplifyframework/storage/options/StorageUploadFileOptions.java @@ -58,10 +58,11 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final StorageUploadFileOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()) - .contentType(options.getContentType()) - .metadata(options.getMetadata()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .contentType(options.getContentType()) + .metadata(options.getMetadata()) + .bucket(options.getBucket()); } /** @@ -88,7 +89,8 @@ public boolean equals(Object obj) { return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && ObjectsCompat.equals(getContentType(), that.getContentType()) && - ObjectsCompat.equals(getMetadata(), that.getMetadata()); + ObjectsCompat.equals(getMetadata(), that.getMetadata()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -102,7 +104,8 @@ public int hashCode() { getAccessLevel(), getTargetIdentityId(), getContentType(), - getMetadata() + getMetadata(), + getBucket() ); } @@ -118,6 +121,7 @@ public String toString() { ", targetIdentityId=" + getTargetIdentityId() + ", contentType=" + getContentType() + ", metadata=" + getMetadata() + + ", bucket=" + getBucket() + '}'; } diff --git a/core/src/main/java/com/amplifyframework/storage/options/StorageUploadInputStreamOptions.java b/core/src/main/java/com/amplifyframework/storage/options/StorageUploadInputStreamOptions.java index ba4623497..9e5c2dac5 100644 --- a/core/src/main/java/com/amplifyframework/storage/options/StorageUploadInputStreamOptions.java +++ b/core/src/main/java/com/amplifyframework/storage/options/StorageUploadInputStreamOptions.java @@ -58,10 +58,11 @@ public static Builder builder() { @SuppressWarnings("deprecation") public static Builder from(@NonNull final StorageUploadInputStreamOptions options) { return builder() - .accessLevel(options.getAccessLevel()) - .targetIdentityId(options.getTargetIdentityId()) - .contentType(options.getContentType()) - .metadata(options.getMetadata()); + .accessLevel(options.getAccessLevel()) + .targetIdentityId(options.getTargetIdentityId()) + .contentType(options.getContentType()) + .metadata(options.getMetadata()) + .bucket(options.getBucket()); } /** @@ -88,7 +89,8 @@ public boolean equals(Object obj) { return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && ObjectsCompat.equals(getContentType(), that.getContentType()) && - ObjectsCompat.equals(getMetadata(), that.getMetadata()); + ObjectsCompat.equals(getMetadata(), that.getMetadata()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -102,7 +104,8 @@ public int hashCode() { getAccessLevel(), getTargetIdentityId(), getContentType(), - getMetadata() + getMetadata(), + getBucket() ); } @@ -118,6 +121,7 @@ public String toString() { ", targetIdentityId=" + getTargetIdentityId() + ", contentType=" + getContentType() + ", metadata=" + getMetadata() + + ", bucket=" + getBucket() + '}'; } diff --git a/core/src/main/java/com/amplifyframework/storage/options/StorageUploadOptions.java b/core/src/main/java/com/amplifyframework/storage/options/StorageUploadOptions.java index 36dcf2a22..9a4144ac9 100644 --- a/core/src/main/java/com/amplifyframework/storage/options/StorageUploadOptions.java +++ b/core/src/main/java/com/amplifyframework/storage/options/StorageUploadOptions.java @@ -41,7 +41,7 @@ public abstract class StorageUploadOptions extends StorageOptions { @SuppressWarnings("deprecation") protected , O extends StorageUploadOptions> StorageUploadOptions(final Builder builder) { - super(builder.getAccessLevel(), builder.getTargetIdentityId()); + super(builder.getAccessLevel(), builder.getTargetIdentityId(), builder.getBucket()); this.contentType = builder.getContentType(); this.metadata = builder.getMetadata(); } @@ -79,7 +79,8 @@ public boolean equals(Object obj) { return ObjectsCompat.equals(getAccessLevel(), that.getAccessLevel()) && ObjectsCompat.equals(getTargetIdentityId(), that.getTargetIdentityId()) && ObjectsCompat.equals(getContentType(), that.getContentType()) && - ObjectsCompat.equals(getMetadata(), that.getMetadata()); + ObjectsCompat.equals(getMetadata(), that.getMetadata()) && + ObjectsCompat.equals(getBucket(), that.getBucket()); } } @@ -93,7 +94,8 @@ public int hashCode() { getAccessLevel(), getTargetIdentityId(), getContentType(), - getMetadata() + getMetadata(), + getBucket() ); } @@ -109,6 +111,7 @@ public String toString() { ", targetIdentityId=" + getTargetIdentityId() + ", contentType=" + getContentType() + ", metadata=" + getMetadata() + + ", bucket=" + getBucket() + '}'; }