Open mbahmani90 opened 2 months ago
@mbahmani90 It does not appear to be possible at this time. I've labeled this ticket as a feature request, and I will also check to see if other Amplify platforms already support this.
As a workaround, I think the best way to get metadata on an object would be to use the escape hatch and use our S3 APIs directly.
Here's an example snippet that makes a HEAD request, fetching only the metadata, not the entire object.
val plugin = Amplify.Storage.getPlugin("awsS3StoragePlugin") as AWSS3StoragePlugin
val client: S3Client = plugin.escapeHatch
val headResponse = client.headObject {
bucket = "<bucket-name>"
key = "public/example.txt"
}
val metadata = headResponse.metadata
Thanks for your support.
I will check your advice soon.
Could you please explain more how it is possible to use headObject:
bucket is not found!
Hi @mbahmani90, replace "<bucket-name>"
with the name of your bucket.
Sorry, I see what you mean. Can you show me your imports?
In the test code I used to test this, I have:
import aws.sdk.kotlin.services.s3.S3Client
import aws.sdk.kotlin.services.s3.headObject
Tylor sorry for the delay in response.
Thank you very much it works.
Only a silly question. Is it secure to use bucket = "
You are a great guy
Bucket is ok to include in code. The bucket is already stored in the amplifyconfiguration.json that is shipped with your application.
Before opening, please confirm:
Language and Async Model
Kotlin, Kotlin - Coroutines
Amplify Categories
Storage
Gradle script dependencies
Environment information
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
Hi,
Hope you are fine.
I want to add some values to a file metadate. According to https://docs.amplify.aws/gen1/android/build-a-backend/storage/upload/ it can define a custom option and put metadata values there. When I check S3 files in the console I can file the metadata which has been stored.
However, I couldn't find a way to read metadata of downloaded file https://docs.amplify.aws/gen1/android/build-a-backend/storage/download/.
Can anyone explain how it is possible to retrieve metadata of a downloaded file?
Thanks
Reproduction steps (if applicable)
No response
Code Snippet
Log output
amplifyconfiguration.json
No response
GraphQL Schema
Additional information and screenshots
No response