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

Switch to v3 AWS SDK #10

Open
Cretezy opened this issue Jul 9, 2023 · 4 comments
Open

Switch to v3 AWS SDK #10

Cretezy opened this issue Jul 9, 2023 · 4 comments

Comments

@Cretezy
Copy link
Contributor

Cretezy commented Jul 9, 2023

v2 will be EOL in 2023, v3 is now recommended.

AWS docs: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/migrating-to-v3.html

Cloudflare docs: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-js-v3/

I just migrated one of my projects, which basically uses the same API as this one, and here are the changes I did:

  • Change aws-sdk to @aws-sdk/client-s3 & @aws-sdk/lib-storage in package.json
  • Use the following to upload files:
    • const s3 = new S3({
        credentials: {
          accessKeyId: process.env.CF_ACCESS_KEY_ID!,
          secretAccessKey: process.env.CF_ACCESS_SECRET!,
        },
        endpoint: process.env.CF_ENDPOINT,
        region: "auto",
      });
      
      await new Upload({
        client: s3,
        params: {
          Key: ...,
          Body: ...,
          ContentType: ...,
          Bucket: process.env.CF_BUCKET!,
        },
      }).done();
@tilman
Copy link
Contributor

tilman commented Jul 10, 2023

Good point 👍 Are you willing to open a PR? Would be great since you already made the migration somewhere else ;)

@Cretezy
Copy link
Contributor Author

Cretezy commented Jul 10, 2023

Yes can look into it!

@anthlasserre
Copy link

Hey guys 👋🏼
I have made the upgrade to V3. Anyone would be able to test it on their side and with a public bucket, please?

@tilman
Copy link
Contributor

tilman commented Jun 2, 2024

Hey guys 👋🏼
I have made the upgrade to V3. Anyone would be able to test it on their side and with a public bucket, please?

Thanks for your PR. Please see my comments on it for some feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants