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

How to use just S3 service out of the whole aws-sdk? #1120

Closed
Sunil6591 opened this issue Aug 31, 2016 · 4 comments
Closed

How to use just S3 service out of the whole aws-sdk? #1120

Sunil6591 opened this issue Aug 31, 2016 · 4 comments
Labels
guidance Question that needs advice or information.

Comments

@Sunil6591
Copy link

I want to use just the S3 services to upload the object and get the list of objects.
The dist of aws-sdk is 1 MB, and i dont need everything, just the S3.
I am looking for something like this

import S3 from 'aws-sdk/s3'

or

import { S3 } from 'aws-sdk'
@chrisradek
Copy link
Contributor

@Sunil6591
Are you using 3rd party tools, like Webpack or Browserify in your project, or are you pulling in the SDK using script tags?
If you're doing the latter, you can use the browser SDK builder to generate an SDK with just the services you want:
https://sdk.amazonaws.com/builder/js/

We are currently working on better webpack support as part of #1117, and are also hoping to address importing individual services, but this is still a work in progress.

@simonbuchan
Copy link

This is now available in 2.6.0:

import S3 from 'aws-sdk/clients/s3';

Take care to avoid any use of the default aws-sdk module, for example for default config or credentials, instead for now:

import 'aws-sdk/lib/node_loader'; // Hack needed before the first import
import { config } from 'aws-sdk/lib/core'; // or any other `aws-sdk` export

Hopefully this is cleaned up soon.

@chrisradek
Copy link
Contributor

To build on top of what @simonbuchan said, if you're using webpack or browserify, you can now require individual services:

var S3 = require('aws-sdk/clients/s3');

You can also still access the AWS namespace that includes only services you've imported:

var AWS = require('aws-sdk/global');

@srchase srchase added the guidance Question that needs advice or information. label Dec 24, 2018
@lock
Copy link

lock bot commented Sep 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

4 participants