aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

How to modify acl policy of a S3 file using v6? #12626

Closed subhankar-trisetra closed 11 months ago

subhankar-trisetra commented 11 months ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Storage

Amplify Categories

storage

Environment information

``` System: OS: macOS 14.1.1 CPU: (8) arm64 Apple M2 Memory: 77.20 MB / 8.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node Yarn: 3.6.3 - ~/.nvm/versions/node/v18.17.1/bin/yarn npm: 10.2.3 - ~/.nvm/versions/node/v18.17.1/bin/npm pnpm: 8.9.2 - ~/.nvm/versions/node/v18.17.1/bin/pnpm bun: 1.0.3 - ~/.bun/bin/bun Browsers: Brave Browser: 119.1.60.118 Chrome: 119.0.6045.159 Safari: 17.1 npmPackages: @aws-amplify/auth: ^5.6.6 => 6.0.5 @aws-amplify/auth/cognito: undefined () @aws-amplify/auth/cognito/server: undefined () @aws-amplify/auth/server: undefined () @belivvr/aframe-react: ^0.4.2 => 0.4.2 @commitlint/cli: ^17.8.1 => 17.8.1 @commitlint/config-conventional: ^17.8.1 => 17.8.1 @google/model-viewer: ~3.3.0 => 3.3.0 @gsid/react-time-ago: ^7.2.5 => 7.2.5 @material-ui/core: ^4.12.4 => 4.12.4 @material-ui/icons: ^4.11.3 => 4.11.3 @material-ui/lab: ^4.0.0-alpha.61 => 4.0.0-alpha.61 @material-ui/styles: ^4.11.5 => 4.11.5 @stripe/react-stripe-js: ^2.4.0 => 2.4.0 @stripe/stripe-js: ^2.2.0 => 2.2.0 @testing-library/jest-dom: ^5.17.0 => 5.17.0 @types/aframe: ^1.2.5 => 1.2.5 @types/chroma-js: ^2.4.3 => 2.4.3 @types/hammerjs: ^2.0.45 => 2.0.45 @types/jest: ^27.5.2 => 27.5.2 (29.5.10) @types/lodash-es: ^4.17.12 => 4.17.12 @types/node: ^18.18.12 => 18.18.13 (20.5.1, 20.10.0) @types/promise-sequential: ^1.1.2 => 1.1.2 @types/react: ^17.0.71 => 17.0.71 @types/react-beautiful-dnd: ^13.1.7 => 13.1.7 @types/react-color: ^3.0.10 => 3.0.10 @types/react-dom: ^17.0.25 => 17.0.25 @types/react-lazy-load-image-component: ^1.6.3 => 1.6.3 @types/react-linkify: ^1.0.4 => 1.0.4 @types/react-router-dom: ^5.3.3 => 5.3.3 @types/three: ~0.158.3 => 0.158.3 @types/tinycolor2: ^1.4.6 => 1.4.6 @types/uuid: ^9.0.7 => 9.0.7 @types/validator: ^13.11.7 => 13.11.7 @types/zen-observable: ^0.8.7 => 0.8.7 @typescript-eslint/eslint-plugin: ^6.12.0 => 6.12.0 (5.62.0) @typescript-eslint/parser: ^6.12.0 => 6.12.0 (5.62.0) @wunderschild/watermarkjs: ^2.1.2 => 2.1.2 aframe: ^1.5.0 => 1.5.0 array-move: ^4.0.0 => 4.0.0 aws-amplify: ^5.3.12 => 6.0.5 aws-amplify/adapter-core: undefined () aws-amplify/analytics: undefined () aws-amplify/analytics/kinesis: undefined () aws-amplify/analytics/kinesis-firehose: undefined () aws-amplify/analytics/personalize: undefined () aws-amplify/analytics/pinpoint: undefined () aws-amplify/api: undefined () aws-amplify/api/server: undefined () aws-amplify/auth: undefined () aws-amplify/auth/cognito: undefined () aws-amplify/auth/cognito/server: undefined () aws-amplify/auth/server: undefined () aws-amplify/datastore: undefined () aws-amplify/in-app-messaging: undefined () aws-amplify/in-app-messaging/pinpoint: undefined () aws-amplify/push-notifications: undefined () aws-amplify/push-notifications/pinpoint: undefined () aws-amplify/storage: undefined () aws-amplify/storage/s3: undefined () aws-amplify/storage/s3/server: undefined () aws-amplify/storage/server: undefined () aws-amplify/utils: undefined () axios: ^1.6.2 => 1.6.2 browser-image-compression: ^2.0.2 => 2.0.2 chroma-js: ^2.4.2 => 2.4.2 clsx: ^2.0.0 => 2.0.0 (1.2.1) color.js: ^1.2.0 => 1.2.0 cross-env: ^7.0.3 => 7.0.3 dexie: ^3.2.4 => 3.2.4 eslint: ^8.54.0 => 8.54.0 eslint-config-airbnb-base: ^15.0.0 => 15.0.0 eslint-config-airbnb-typescript: ^17.1.0 => 17.1.0 eslint-config-prettier: ^8.10.0 => 8.10.0 eslint-plugin-import: ^2.29.0 => 2.29.0 eslint-plugin-jest: ^27.6.0 => 27.6.0 (25.7.0) eslint-plugin-jest-formatting: ^3.1.0 => 3.1.0 eslint-plugin-prettier: ^4.2.1 => 4.2.1 eslint-plugin-react: ^7.33.2 => 7.33.2 eslint-plugin-simple-import-sort: ^10.0.0 => 10.0.0 eslint-plugin-unused-imports: ^3.0.0 => 3.0.0 formik: ^2.4.5 => 2.4.5 hammerjs: ^2.0.8 => 2.0.8 heic2any: ^0.0.4 => 0.0.4 history: ^5.3.0 => 5.3.0 (4.10.1) html2canvas: ^1.4.1 => 1.4.1 husky: ^8.0.3 => 8.0.3 javascript-time-ago: ^2.5.9 => 2.5.9 javascript-time-ago/cache: undefined () javascript-time-ago/commonjs: undefined () javascript-time-ago/gradation: undefined () javascript-time-ago/load-all-locales: undefined () javascript-time-ago/locale/af: undefined () javascript-time-ago/locale/am: undefined () javascript-time-ago/locale/ar: undefined () javascript-time-ago/locale/ar-AE: undefined () javascript-time-ago/locale/as: undefined () javascript-time-ago/locale/ast: undefined () javascript-time-ago/locale/az: undefined () javascript-time-ago/locale/be: undefined () javascript-time-ago/locale/bg: undefined () javascript-time-ago/locale/bgc: undefined () javascript-time-ago/locale/bn: undefined () javascript-time-ago/locale/br: undefined () javascript-time-ago/locale/brx: undefined () javascript-time-ago/locale/bs: undefined () javascript-time-ago/locale/bs-Cyrl: undefined () javascript-time-ago/locale/ca: undefined () javascript-time-ago/locale/ccp: undefined () javascript-time-ago/locale/ce: undefined () javascript-time-ago/locale/ceb: undefined () javascript-time-ago/locale/chr: undefined () javascript-time-ago/locale/cs: undefined () javascript-time-ago/locale/cv: undefined () javascript-time-ago/locale/cy: undefined () javascript-time-ago/locale/da: undefined () javascript-time-ago/locale/de: undefined () javascript-time-ago/locale/dsb: undefined () javascript-time-ago/locale/dz: undefined () javascript-time-ago/locale/ee: undefined () javascript-time-ago/locale/el: undefined () javascript-time-ago/locale/en: undefined () javascript-time-ago/locale/en-001: undefined () javascript-time-ago/locale/en-150: undefined () javascript-time-ago/locale/en-AG: undefined () javascript-time-ago/locale/en-AI: undefined () javascript-time-ago/locale/en-AT: undefined () javascript-time-ago/locale/en-AU: undefined () javascript-time-ago/locale/en-BB: undefined () javascript-time-ago/locale/en-BE: undefined () javascript-time-ago/locale/en-BM: undefined () javascript-time-ago/locale/en-BS: undefined () javascript-time-ago/locale/en-BW: undefined () javascript-time-ago/locale/en-BZ: undefined () javascript-time-ago/locale/en-CA: undefined () javascript-time-ago/locale/en-CC: undefined () javascript-time-ago/locale/en-CH: undefined () javascript-time-ago/locale/en-CK: undefined () javascript-time-ago/locale/en-CM: undefined () javascript-time-ago/locale/en-CX: undefined () javascript-time-ago/locale/en-CY: undefined () javascript-time-ago/locale/en-DE: undefined () javascript-time-ago/locale/en-DG: undefined () javascript-time-ago/locale/en-DK: undefined () javascript-time-ago/locale/en-DM: undefined () javascript-time-ago/locale/en-ER: undefined () javascript-time-ago/locale/en-FI: undefined () javascript-time-ago/locale/en-FJ: undefined () javascript-time-ago/locale/en-FK: undefined () javascript-time-ago/locale/en-FM: undefined () javascript-time-ago/locale/en-GB: undefined () javascript-time-ago/locale/en-GD: undefined () javascript-time-ago/locale/en-GG: undefined () javascript-time-ago/locale/en-GH: undefined () javascript-time-ago/locale/en-GI: undefined () javascript-time-ago/locale/en-GM: undefined () javascript-time-ago/locale/en-GY: undefined () javascript-time-ago/locale/en-HK: undefined () javascript-time-ago/locale/en-IE: undefined () javascript-time-ago/locale/en-IL: undefined () javascript-time-ago/locale/en-IM: undefined () javascript-time-ago/locale/en-IN: undefined () javascript-time-ago/locale/en-IO: undefined () javascript-time-ago/locale/en-JE: undefined () javascript-time-ago/locale/en-JM: undefined () javascript-time-ago/locale/en-KE: undefined () javascript-time-ago/locale/en-KI: undefined () javascript-time-ago/locale/en-KN: undefined () javascript-time-ago/locale/en-KY: undefined () javascript-time-ago/locale/en-LC: undefined () javascript-time-ago/locale/en-LR: undefined () javascript-time-ago/locale/en-LS: undefined () javascript-time-ago/locale/en-MG: undefined () javascript-time-ago/locale/en-MO: undefined () javascript-time-ago/locale/en-MS: undefined () javascript-time-ago/locale/en-MT: undefined () javascript-time-ago/locale/en-MU: undefined () javascript-time-ago/locale/en-MV: undefined () javascript-time-ago/locale/en-MW: undefined () javascript-time-ago/locale/en-MY: undefined () javascript-time-ago/locale/en-NA: undefined () javascript-time-ago/locale/en-NF: undefined () javascript-time-ago/locale/en-NG: undefined () javascript-time-ago/locale/en-NL: undefined () javascript-time-ago/locale/en-NR: undefined () javascript-time-ago/locale/en-NU: undefined () javascript-time-ago/locale/en-NZ: undefined () javascript-time-ago/locale/en-PG: undefined () javascript-time-ago/locale/en-PK: undefined () javascript-time-ago/locale/en-PN: undefined () javascript-time-ago/locale/en-PW: undefined () javascript-time-ago/locale/en-RW: undefined () javascript-time-ago/locale/en-SB: undefined () javascript-time-ago/locale/en-SC: undefined () javascript-time-ago/locale/en-SD: undefined () javascript-time-ago/locale/en-SE: undefined () javascript-time-ago/locale/en-SG: undefined () javascript-time-ago/locale/en-SH: undefined () javascript-time-ago/locale/en-SI: undefined () javascript-time-ago/locale/en-SL: undefined () javascript-time-ago/locale/en-SS: undefined () javascript-time-ago/locale/en-SX: undefined () javascript-time-ago/locale/en-SZ: undefined () javascript-time-ago/locale/en-TC: undefined () javascript-time-ago/locale/en-TK: undefined () javascript-time-ago/locale/en-TO: undefined () javascript-time-ago/locale/en-TT: undefined () javascript-time-ago/locale/en-TV: undefined () javascript-time-ago/locale/en-TZ: undefined () javascript-time-ago/locale/en-UG: undefined () javascript-time-ago/locale/en-VC: undefined () javascript-time-ago/locale/en-VG: undefined () javascript-time-ago/locale/en-VU: undefined () javascript-time-ago/locale/en-WS: undefined () javascript-time-ago/locale/en-ZA: undefined () javascript-time-ago/locale/en-ZM: undefined () javascript-time-ago/locale/en-ZW: undefined () javascript-time-ago/locale/eo: undefined () javascript-time-ago/locale/es: undefined () javascript-time-ago/locale/es-419: undefined () javascript-time-ago/locale/es-AR: undefined () javascript-time-ago/locale/es-BO: undefined () javascript-time-ago/locale/es-BR: undefined () javascript-time-ago/locale/es-BZ: undefined () javascript-time-ago/locale/es-CL: undefined () javascript-time-ago/locale/es-CO: undefined () javascript-time-ago/locale/es-CR: undefined () javascript-time-ago/locale/es-CU: undefined () javascript-time-ago/locale/es-DO: undefined () javascript-time-ago/locale/es-EC: undefined () javascript-time-ago/locale/es-GT: undefined () javascript-time-ago/locale/es-HN: undefined () javascript-time-ago/locale/es-MX: undefined () javascript-time-ago/locale/es-NI: undefined () javascript-time-ago/locale/es-PA: undefined () javascript-time-ago/locale/es-PE: undefined () javascript-time-ago/locale/es-PR: undefined () javascript-time-ago/locale/es-PY: undefined () javascript-time-ago/locale/es-SV: undefined () javascript-time-ago/locale/es-US: undefined () javascript-time-ago/locale/es-UY: undefined () javascript-time-ago/locale/es-VE: undefined () javascript-time-ago/locale/et: undefined () javascript-time-ago/locale/eu: undefined () javascript-time-ago/locale/fa: undefined () javascript-time-ago/locale/ff-Adlm: undefined () javascript-time-ago/locale/fi: undefined () javascript-time-ago/locale/fil: undefined () javascript-time-ago/locale/fo: undefined () javascript-time-ago/locale/fr: undefined () javascript-time-ago/locale/fr-CA: undefined () javascript-time-ago/locale/fur: undefined () javascript-time-ago/locale/fy: undefined () javascript-time-ago/locale/ga: undefined () javascript-time-ago/locale/gd: undefined () javascript-time-ago/locale/gl: undefined () javascript-time-ago/locale/gu: undefined () javascript-time-ago/locale/ha: undefined () javascript-time-ago/locale/he: undefined () javascript-time-ago/locale/hi: undefined () javascript-time-ago/locale/hi-Latn: undefined () javascript-time-ago/locale/hr: undefined () javascript-time-ago/locale/hsb: undefined () javascript-time-ago/locale/hu: undefined () javascript-time-ago/locale/hy: undefined () javascript-time-ago/locale/ia: undefined () javascript-time-ago/locale/id: undefined () javascript-time-ago/locale/ig: undefined () javascript-time-ago/locale/is: undefined () javascript-time-ago/locale/it: undefined () javascript-time-ago/locale/ja: undefined () javascript-time-ago/locale/jgo: undefined () javascript-time-ago/locale/jv: undefined () javascript-time-ago/locale/ka: undefined () javascript-time-ago/locale/kea: undefined () javascript-time-ago/locale/kgp: undefined () javascript-time-ago/locale/kk: undefined () javascript-time-ago/locale/kl: undefined () javascript-time-ago/locale/km: undefined () javascript-time-ago/locale/kn: undefined () javascript-time-ago/locale/ko: undefined () javascript-time-ago/locale/kok: undefined () javascript-time-ago/locale/ks: undefined () javascript-time-ago/locale/ksh: undefined () javascript-time-ago/locale/ku: undefined () javascript-time-ago/locale/ky: undefined () javascript-time-ago/locale/lb: undefined () javascript-time-ago/locale/lkt: undefined () javascript-time-ago/locale/lo: undefined () javascript-time-ago/locale/lt: undefined () javascript-time-ago/locale/lv: undefined () javascript-time-ago/locale/mai: undefined () javascript-time-ago/locale/mi: undefined () javascript-time-ago/locale/mk: undefined () javascript-time-ago/locale/ml: undefined () javascript-time-ago/locale/mn: undefined () javascript-time-ago/locale/mni: undefined () javascript-time-ago/locale/mr: undefined () javascript-time-ago/locale/ms: undefined () javascript-time-ago/locale/mt: undefined () javascript-time-ago/locale/my: undefined () javascript-time-ago/locale/mzn: undefined () javascript-time-ago/locale/nb: undefined () javascript-time-ago/locale/ne: undefined () javascript-time-ago/locale/nl: undefined () javascript-time-ago/locale/nn: undefined () javascript-time-ago/locale/no: undefined () javascript-time-ago/locale/or: undefined () javascript-time-ago/locale/pa: undefined () javascript-time-ago/locale/pcm: undefined () javascript-time-ago/locale/pl: undefined () javascript-time-ago/locale/ps: undefined () javascript-time-ago/locale/ps-PK: undefined () javascript-time-ago/locale/pt: undefined () javascript-time-ago/locale/pt-AO: undefined () javascript-time-ago/locale/pt-CH: undefined () javascript-time-ago/locale/pt-CV: undefined () javascript-time-ago/locale/pt-GQ: undefined () javascript-time-ago/locale/pt-GW: undefined () javascript-time-ago/locale/pt-LU: undefined () javascript-time-ago/locale/pt-MO: undefined () javascript-time-ago/locale/pt-MZ: undefined () javascript-time-ago/locale/pt-PT: undefined () javascript-time-ago/locale/pt-ST: undefined () javascript-time-ago/locale/pt-TL: undefined () javascript-time-ago/locale/qu: undefined () javascript-time-ago/locale/raj: undefined () javascript-time-ago/locale/rm: undefined () javascript-time-ago/locale/ro: undefined () javascript-time-ago/locale/ru: undefined () javascript-time-ago/locale/sah: undefined () javascript-time-ago/locale/sc: undefined () javascript-time-ago/locale/sd: undefined () javascript-time-ago/locale/se: undefined () javascript-time-ago/locale/se-FI: undefined () javascript-time-ago/locale/si: undefined () javascript-time-ago/locale/sk: undefined () javascript-time-ago/locale/sl: undefined () javascript-time-ago/locale/so: undefined () javascript-time-ago/locale/sq: undefined () javascript-time-ago/locale/sr: undefined () javascript-time-ago/locale/sr-Cyrl-BA: undefined () javascript-time-ago/locale/sr-Latn: undefined () javascript-time-ago/locale/sr-Latn-BA: undefined () javascript-time-ago/locale/su: undefined () javascript-time-ago/locale/sv: undefined () javascript-time-ago/locale/sw: undefined () javascript-time-ago/locale/ta: undefined () javascript-time-ago/locale/te: undefined () javascript-time-ago/locale/tg: undefined () javascript-time-ago/locale/th: undefined () javascript-time-ago/locale/ti: undefined () javascript-time-ago/locale/tk: undefined () javascript-time-ago/locale/to: undefined () javascript-time-ago/locale/tr: undefined () javascript-time-ago/locale/tt: undefined () javascript-time-ago/locale/ug: undefined () javascript-time-ago/locale/uk: undefined () javascript-time-ago/locale/ur: undefined () javascript-time-ago/locale/ur-IN: undefined () javascript-time-ago/locale/uz: undefined () javascript-time-ago/locale/uz-Cyrl: undefined () javascript-time-ago/locale/vi: undefined () javascript-time-ago/locale/wae: undefined () javascript-time-ago/locale/wo: undefined () javascript-time-ago/locale/xh: undefined () javascript-time-ago/locale/yi: undefined () javascript-time-ago/locale/yo: undefined () javascript-time-ago/locale/yo-BJ: undefined () javascript-time-ago/locale/yrl: undefined () javascript-time-ago/locale/yue: undefined () javascript-time-ago/locale/yue-Hans: undefined () javascript-time-ago/locale/zh: undefined () javascript-time-ago/locale/zh-Hans-HK: undefined () javascript-time-ago/locale/zh-Hans-MO: undefined () javascript-time-ago/locale/zh-Hans-SG: undefined () javascript-time-ago/locale/zh-Hant: undefined () javascript-time-ago/locale/zh-Hant-HK: undefined () javascript-time-ago/locale/zh-Hant-MO: undefined () javascript-time-ago/locale/zu: undefined () javascript-time-ago/prop-types: undefined () javascript-time-ago/steps: undefined () jest: ^27.5.1 => 27.5.1 lint-staged: ^14.0.1 => 14.0.1 lodash-es: ^4.17.21 => 4.17.21 mobx: ^6.11.0 => 6.11.0 mobx-react: ^9.1.0 => 9.1.0 notistack: ^1.0.10 => 1.0.10 pinst: ^3.0.0 => 3.0.0 prettier: ^2.8.8 => 2.8.8 promise-sequential: ^1.1.1 => 1.1.1 react: ^17.0.2 => 17.0.2 react-beautiful-dnd: ^13.1.1 => 13.1.1 react-color: ^2.19.3 => 2.19.3 react-day-and-night-toggle: ^1.0.18 => 1.0.18 react-document-crop: ^0.3.1 => 0.3.1 react-dom: ^17.0.2 => 17.0.2 react-dots-loader: ^1.1.4 => 1.1.4 react-dropzone: ^14.2.3 => 14.2.3 react-ga4: ^2.1.0 => 2.1.0 react-idle-timer: ^5.7.2 => 5.7.2 react-lazy-load-image-component: ^1.6.0 => 1.6.0 react-linkify: ^1.0.0-alpha => 1.0.0-alpha react-router-dom: ^5.3.4 => 5.3.4 react-scripts: ^5.0.1 => 5.0.1 react-sortable-hoc: ^2.0.0 => 2.0.0 react-time-ago/commonjs: undefined () rimraf: ^5.0.5 => 5.0.5 (3.0.2, 2.6.3) sass: ^1.69.5 => 1.69.5 serve: ^14.2.1 => 14.2.1 source-map-explorer: ^2.5.3 => 2.5.3 stripe: ^13.11.0 => 13.11.0 styled-components: ^5.3.11 => 5.3.11 styled-components/macro: undefined () styled-components/native: undefined () styled-components/primitives: undefined () three: ~0.158.0 => 0.158.0 tinycolor2: ^1.6.0 => 1.6.0 ts-jest: ^27.1.5 => 27.1.5 typescript: ^5.3.2 => 5.3.2 use-eye-dropper: ^1.6.0 => 1.6.0 uuid: ^9.0.1 => 9.0.1 (8.3.2) validator: ^13.11.0 => 13.11.0 vconsole: ^3.15.1 => 3.15.1 npmGlobalPackages: corepack: 0.18.0 imagemin-advpng: 6.0.0 imagemin-cli: 7.0.0 imagemin-gifsicle: 7.0.0 imagemin-jpegtran: 7.0.0 imagemin-pngcrush: 7.0.0 imagemin-pngout: 5.0.0 imagemin-svgo: 10.0.1 imagemin-webp: 8.0.0 npm-check-updates: 16.14.11 npm: 10.2.3 pnpm: 8.9.2 prettier: 3.0.3 serve: 14.2.1 serverless: 3.35.0 ts-node: 10.9.1 typedoc: 0.25.3 yarn: 1.22.19 ```

Describe the bug

Previously I could set the acl using the v5 api, however I'm not able to do that in v6. Any solution to that? Or how is it working internally?

Expected behavior

I'm thinking acl should be present in the current uploadData function.

Reproduction steps

NA

Code Snippet

// v6
uploadData({
  key,
  data: file,
  options: {
    accessLevel: 'guest',
    contentType: file.type,
    onProgress: (ev) => {
      uploadProgressHandler(idx, Math.round((ev.transferredBytes / (ev.totalBytes ?? 1)) * 100));
    },
  }
});

// v5
Storage.put(key, file, {
  contentType: file.type,
  level: 'public',
  acl: 'public-read',
  progressCallback: (ev: ProgressEvent) => {
    uploadProgressHandler(idx, Math.round((ev.loaded / ev.total) * 100));
  },
});

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

nadetastic commented 11 months ago

Hi @subhankar-trisetra thank you for opening this issue. Please note that the parameter for modifying the ACL policy is no longer available with V6. Could you provide some context to what you are looking to achieve with this?

subhankar-trisetra commented 11 months ago

Right, thanks for the response, so the thing is I want the user to be able to upload a file in the level=public folder which aren't shared by other users in the app, however if the user wants a file to be shared as a link, then the putting the acl=public-read helps a lot.

subhankar-trisetra commented 11 months ago

Was there any particular reason for the removal of that parameter? AFAIK, that should be a slight param change in the underlying aws-sdk call right?

nadetastic commented 11 months ago

@subhankar-trisetra i see, thanks for providing context. One of the reasons this has been deprecated is it is not considered best practice to utilize ACLs as described by S3. Im wondering if there's an alternative for you use case - have you considered using the private or protected levels for a file not shared by other users, then moving the file (by copying it) over to the public level that is accessible by other users?

cwomack commented 11 months ago

@subhankar-trisetra, we no longer support the use of the acl input option in v6 due to Amazon S3 service providing more control over ACL's directly. We'll close this issue due to this change being by design, but if there's further issues using the ACL's controls directly in the S3 console then let us know!

AndreasEK commented 8 months ago

@cwomack we have an s3 bucket that hosts images, which are uploaded by different users. Those images are intentionally uploaded as 'protected' (so that users cannot overwrite each others images), but are acl: public-read, so that anybody can anonymously retrieve the image via a cachable url. Please enlighten me, how this can be achieved in amplify v6. 1) Can we set the acl manually after uploading with amplify? I guess we would need to import the standard aws javascript library for that. A "bridge" from amplify to aws would be nice, tbh for use cases that go beyond the standard amplify way of doing things. 2) Can we set some acl or policy on bucket level? As far as I can see, on bucket level, one can only grant a "list" permission. but in order to get the actual object, it need's to be set on object level.

I've spend the better part of the afternoon now trying to figure that out on my own, but (a) the documentation is

So … what do we do? What have you done @subhankar-trisetra ?

subhankar-trisetra commented 8 months ago

I still haven't found a solution to this without changing our whole app architecture in terms of storage. We're still using v5 for now.

AndreasEK commented 8 months ago

That makes me sad

AndreasEK commented 8 months ago

@subhankar-trisetra I've found a workaround for us. Maybe this is interesting for you, too.

I've used an override for the generated amplify resource.

The bucketName section was already present in the override.ts, because some earlier amplify upgrade decided to default to a different naming convention for buckets. The addCfnResource adds a new resource to the cloudformation template. In our case it's a BucketPolicy.

So - even if this might not solve your requirements, maybe this sparks an idea.

import { AmplifyS3ResourceTemplate } from '@aws-amplify/cli-extensibility-helper';

// AmplifyS3ResourceTemplate | see https://github.com/aws-amplify/amplify-cli/issues/9063#issuecomment-1034426494
export function override(resources: any) {
  resources.s3Bucket.bucketName = {
    'Fn::If': [
      'ShouldNotCreateEnvResources',
      {
        Ref: 'bucketName',
      },
      {
        'Fn::Join': [
          '',
          [
            {
              Ref: 'bucketName',
            },
            '-',
            {
              Ref: 'env',
            },
          ],
        ],
      },
    ],
  };
  resources.addCfnResource(
    {
      type: 'AWS::S3::BucketPolicy',
      properties: {
        Bucket: resources.s3Bucket.bucketName,
        PolicyDocument: {
          Version: '2012-10-17',
          Id: 'Policy1708334814278',
          Statement: [
            {
              Sid: 'Stmt1708334806707',
              Effect: 'Allow',
              Principal: '*',
              Action: 's3:GetObject',
              Resource: {
                'Fn::Join': [
                  '',
                  ['arn:aws:s3:::', resources.s3Bucket.bucketName, '/*'],
                ],
              },
            },
          ],
        },
      },
    },
    'PublicReadBucketPolicy',
  );
}