-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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): getProperties API #11378
feat(storage): getProperties API #11378
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #11378 +/- ##
=======================================
Coverage 82.99% 82.99%
=======================================
Files 240 240
Lines 20163 20179 +16
Branches 4355 4358 +3
=======================================
+ Hits 16734 16748 +14
- Misses 3142 3144 +2
Partials 287 287
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! One comment below about SSE support.
const s3 = this._createNewS3Client(opt, emitter); | ||
logger.debug('getProperties ' + key + ' from ' + final_key); | ||
|
||
const params: HeadObjectCommandInput = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this API should support SSE to align with the other APIs (HeadObject
command supports it it looks like). It would be strange if you can upload/download SSE-enabled objects but can't get the meta-data for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added SSE support!
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me generally and have minor comments in for the test. I think we need to confirm whether SSE parameters can be omitted before merging it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀🚀🚀
packages/storage/src/Storage.ts
Outdated
config?: StorageGetPropertiesConfig<T> | ||
): StorageGetPropertiesOutput<T> { | ||
const provider = config?.provider || DEFAULT_PROVIDER; | ||
const prov = this._pluggables.find( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: prov
can be made more descriptive? Also there seems to be a util function to get the provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢🚢🚢
await storage.put('key', 'test upload'); | ||
} catch (err) { | ||
expect(err).toEqual('No plugin found in Storage for the provider'); | ||
expect(err).toEqual(new Error('No plugin found with providerName')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It would be a little cleaner (here and elsewhere) to test failure modes like this:
await expect(storage.put('key', 'test upload')).rejects.toThrow(new Error('No plugin found with providerName'));
packages/storage/src/Storage.ts
Outdated
return null; | ||
throw new Error('No plugin found with providerName'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach makes sense and is cleaner, but I'm just worried if this might constitute a breaking change on a public API surface for folks who may have implemented their own providers or be using this method directly in some non-standard ward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's a valid point. Thanks.
packages/storage/src/Storage.ts
Outdated
const prov = this._pluggables.find( | ||
pluggable => pluggable.getProviderName() === provider | ||
); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
return Promise.reject( | ||
'No plugin found in Storage for the provider' | ||
) as StorageCopyOutput<T>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for cleaning this up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work
This reverts commit 3bed12b.
* chore(release): Publish [ci skip] - aws-amplify@5.2.3 - @aws-amplify/datastore-storage-adapter@2.0.33 - @aws-amplify/datastore@4.4.0 - @aws-amplify/predictions@5.2.0 - @aws-amplify/storage@5.3.0 * chore(release): update API docs [ci skip] * fix(notifications): Add babel plugins to devDependencies (#11414) * fix(storage): make getProperties param optional (#11413) * Revert "fix(storage): make getProperties param optional (#11413)" This reverts commit 5d00b1f. * Revert "feat(storage): getProperties API (#11378)" This reverts commit 3bed12b. --------- Co-authored-by: israx <70438514+israx@users.noreply.github.com> Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com> Co-authored-by: Jim Blanchard <jablanch@amazon.com> Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
* chore(release): Publish [ci skip] - aws-amplify@5.2.3 - @aws-amplify/datastore-storage-adapter@2.0.33 - @aws-amplify/datastore@4.4.0 - @aws-amplify/predictions@5.2.0 - @aws-amplify/storage@5.3.0 * chore(release): update API docs [ci skip] * fix(notifications): Add babel plugins to devDependencies (#11414) * fix(storage): make getProperties param optional (#11413) * Revert "fix(storage): make getProperties param optional (#11413)" This reverts commit 5d00b1f. * Revert "feat(storage): getProperties API (#11378)" This reverts commit 3bed12b. * fix(core): bundle react-native-url-polyfill to unblock jest test failure (#11422) * fix(core): bundle react-native-url-polyfill to unblock jest test failure * Revert "test(notification): unblock unit test failure of rn url polyfill" This reverts commit dbacebc. * chore: remove unused code * chore: remove unused polyfills/URL/package.json * chore(release): Publish [ci skip] - @aws-amplify/analytics@6.1.1 - @aws-amplify/api-graphql@3.2.1 - @aws-amplify/api-rest@3.1.1 - @aws-amplify/api@5.1.1 - @aws-amplify/auth@5.3.7 - aws-amplify@5.2.4 - @aws-amplify/cache@5.0.33 - @aws-amplify/core@5.3.1 - @aws-amplify/datastore-storage-adapter@2.0.34 - @aws-amplify/datastore@4.4.1 - @aws-amplify/geo@2.0.33 - @aws-amplify/interactions@5.0.33 - @aws-amplify/notifications@1.1.7 - @aws-amplify/predictions@5.2.1 - @aws-amplify/pubsub@5.1.16 - @aws-amplify/pushnotification@5.0.33 - @aws-amplify/storage@5.3.1 * chore(release): update API docs [ci skip] --------- Co-authored-by: israx <70438514+israx@users.noreply.github.com> Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com> Co-authored-by: Jim Blanchard <jablanch@amazon.com> Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com> Co-authored-by: AllanZhengYP <zheallan@amazon.com>
Description of changes
This api enables users to retrieve properties of object from storage.
Issue #, if available
#6830
#1550
Description of how you validated changes
Tested with a sample app and added unit test cases
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.