Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage): Gen2 Storage Download/Upload #2741

Merged
merged 46 commits into from
Apr 4, 2024

Conversation

tylerjroach
Copy link
Member

  • PR title and description conform to Pull Request guidelines.

Issue #, if available:

Description of changes:

How did you test these changes?
(Please add a line here how the changes were tested)

Documentation update required?

  • No
  • Yes (Please include a PR link for the documentation update)

General Checklist

  • Added Unit Tests
  • Added Integration Tests
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Base automatically changed from tjroach/gen2-storage-contract to feat/gen2-storage March 27, 2024 19:37
…pload

# Conflicts:
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/AWSS3StoragePlugin.java
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/extensions/StorageExceptionExtensions.kt
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/operation/AWSS3StorageDownloadFileOperation.kt
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/operation/AWSS3StorageGetPresignedUrlOperation.java
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/operation/AWSS3StorageListOperation.java
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/operation/AWSS3StoragePathDownloadFileOperation.kt
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/operation/AWSS3StorageRemoveOperation.java
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/operation/AWSS3StorageUploadFileOperation.kt
#	aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/operation/AWSS3StorageUploadInputStreamOperation.kt
#	core-kotlin/src/test/java/com/amplifyframework/kotlin/storage/KotlinStorageFacadeTest.kt
#	core/src/main/java/com/amplifyframework/storage/StoragePath.kt
#	core/src/main/java/com/amplifyframework/storage/StoragePathValidationException.kt
#	core/src/main/java/com/amplifyframework/storage/result/StorageUploadFileResult.java
@tylerjroach tylerjroach marked this pull request as ready for review March 27, 2024 19:52
@tylerjroach tylerjroach requested a review from a team as a code owner March 27, 2024 19:52
@@ -0,0 +1,271 @@
/*
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 2024

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to go through and check all my licenses. This one is a copy/paste issue, but I believe my auto license header was disabled and not applied to some of the new files. Will make a note.

@tylerjroach
Copy link
Member Author

Looks like I didn't include upload file/inputstream integration tests on this PR. Will add to follow up

}
is IdentityIdProvidedStoragePath -> {
val identityId = try {
runBlocking {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this function suspend and lift this runBlocking out to where we dispatch to the executors so that it's clear what's happening there.

In the future we will (hopefully 🤞) make the plugin fully coroutine-based and it'll be easier to understand if the borders between concurrency models are as co-located as possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will make this change in follow up pr

@@ -38,8 +38,8 @@ import java.util.concurrent.ExecutorService
* An operation to download a file from AWS S3.
*/
@Deprecated(
"Class should not be public and explicitly cast to. " +
"Internal usages are moving to AWSS3StorageDownloadFileOperationV2"
"Class should not be public and explicitly cast to. Case to StorageDownloadFileOperation." +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*cast

@JvmStatic
fun fromIdentityId(identityIdPathResolver: IdentityIdPathResolver): StoragePath =
IdentityIdProvidedStoragePath(identityIdPathResolver)
}
}

/**
* StoragePath that was created with the full String path.
*/
data class StringStoragePath internal constructor(private val path: String) : StoragePath() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these classes be @InternalAmplifyApi?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked on api review and there could be some valid reason to check type that we decided it was valid to expose.

/**
* An operation to upload a file from AWS S3.
*/
internal class AWSS3StoragePathUploadFileOperation @JvmOverloads internal constructor(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need @JvmOverloads on these operation constructors? Seems like the plugin is always supplying all values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove. This was from copy paste

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove on InputStream operation as well.

@mattcreaser
Copy link
Member

General comment: the *Operation classes have a lot of duplicated logic. I know that's how the existing classes are already written but we could certainly reduce that by using composition patterns in a future refactor.

@tylerjroach tylerjroach merged commit 63bc45d into feat/gen2-storage Apr 4, 2024
2 checks passed
@tylerjroach tylerjroach deleted the tjroach/gen2-storage-download-upload branch April 4, 2024 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants