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

TransferUtility.upload()'s TransferObserver or TransferListener should include the eTag of uploaded file #2926

Open
1 task done
kenyee opened this issue Sep 22, 2024 · 2 comments
Labels
feature-request Request a new feature storage Related to the Storage category/plugins

Comments

@kenyee
Copy link

kenyee commented Sep 22, 2024

Before opening, please confirm:

Language and Async Model

Kotlin, Kotlin - Coroutines

Amplify Categories

Storage

Gradle script dependencies

com-amazonaws = "2.77.0"
com-amazonaws-aws-android-sdk-s3 = { module = "com.amazonaws:aws-android-sdk-s3", version.ref = "com-amazonaws" }

Environment information

N.A.

Please include any relevant guides or documentation you're referencing

https://docs.amplify.aws/android/build-a-backend/storage/upload-files/

Describe the feature request

The use case is that temporary credentials are used to upload to a server but we also need to include the eTag to make sure we have the latest version of a file. However, the credentials don't allow .getObject or .getObjectMetadata calls for security reasons.

Using TransferObserver, you get the id and state but not the eTag:

object : TransferListener {
                    override fun onStateChanged(
                        id: Int,
                        state: TransferState,
                    ) {
                        if (TransferState.COMPLETED == state) {
                            continuation.resume(state.name)
                        } else {
                            Timber.d("State changed to ${state.name}")
                        }
                    }

Please include the eTag in the onStateChanged parameters. Or include it in the fields of the TransferObserver when it's completed.

Initialization steps (if applicable)

No response

Code Snippet

// Put your code below this line.

amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Sep 22, 2024
@kenyee
Copy link
Author

kenyee commented Sep 22, 2024

Forgot to mention, this is what we currently do to upload a file to S3:

suspend fun uploadWithPutObject(
        ioDispatcher: CoroutineDispatcher,
        s3Client: AmazonS3Client,
        s3Bucket: String,
        s3FileKeyName: String,
        file: File,
    ): String =
        withContext(ioDispatcher) {
            s3Client.putObject(s3Bucket, s3FileKeyName, file).eTag
        }

@phantumcode phantumcode added feature-request Request a new feature storage Related to the Storage category/plugins labels Sep 23, 2024
@github-actions github-actions bot removed the pending-triage Issue is pending triage label Sep 23, 2024
@phantumcode
Copy link
Member

Thanks for submitting the feature request. Our team will prioritize the request and provide updates here.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature storage Related to the Storage category/plugins
Projects
None yet
Development

No branches or pull requests

2 participants