Hi, how do I make my S3 files accessible to the ot...
# sst
s
Hi, how do I make my S3 files accessible to the other users in the system? Now only the person uploaded the files can access them in the fronend.
f
Hey @Selo, if your setup is similar to this in the guide:
Copy code
auth.attachPermissionsForAuthUsers([
    // Allow access to the API
    api,
    // Policy granting access to a specific folder in the bucket
    new iam.PolicyStatement({
      actions: ["s3:*"],
      effect: iam.Effect.ALLOW,
      resources: [
        bucket.bucketArn + "/private/${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*",
      ],
    }),
  ]);
Here we are saying that users can only access files in this path
/private/$userId/*
and the files are uploaded to here.
Instead, u can upload files to the
/public
folder, and grant access to
/public
, ie.
Copy code
auth.attachPermissionsForAuthUsers([
    ...
    // Policy granting access to the public folder in the bucket
    new iam.PolicyStatement({
      actions: ["s3:*"],
      effect: iam.Effect.ALLOW,
      resources: [bucket.bucketArn + "/public/*"],
    }),
  ]);
Lemme know if that makes sense.
s
Yes this make sense thanks a lot