How to use @aws-sdk/client-s3 - 3 common examples

To help you get started, we’ve selected a few @aws-sdk/client-s3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awsdocs / aws-doc-sdk-examples / javascript / example_code / nodegetstarted / sampleV3.js View on Github external
const {
    S3Client,
    CreateBucketCommand,
    PutObjectCommand
  } = require('@aws-sdk/client-s3')
  
  var uuid = require('uuid')

  // Unique bucket name
  const bucketName = 'node-sdk-sample-' + uuid.v4()
  // Name for uploaded object
  const keyName = 'hello_world.txt'

  const client = new S3Client({})

  const createCommand = new CreateBucketCommand({
    Bucket: bucketName
  })

  const putCommand = new PutObjectCommand({
    Bucket: bucketName,
    Key: keyName,
    Body: 'Hello World!'
  })

  try {
    await client.send(createCommand)
    await client.send(putCommand)
    console.log('Successfully uploaded data to ' + bucketName + '/' + keyName)
  } catch (err) {
    console.error(err, err.stack)
  }
github awsdocs / aws-doc-sdk-examples / javascript / example_code / nodegetstarted / sampleV3.js View on Github external
} = require('@aws-sdk/client-s3')
  
  var uuid = require('uuid')

  // Unique bucket name
  const bucketName = 'node-sdk-sample-' + uuid.v4()
  // Name for uploaded object
  const keyName = 'hello_world.txt'

  const client = new S3Client({})

  const createCommand = new CreateBucketCommand({
    Bucket: bucketName
  })

  const putCommand = new PutObjectCommand({
    Bucket: bucketName,
    Key: keyName,
    Body: 'Hello World!'
  })

  try {
    await client.send(createCommand)
    await client.send(putCommand)
    console.log('Successfully uploaded data to ' + bucketName + '/' + keyName)
  } catch (err) {
    console.error(err, err.stack)
  }
})()
// snippet-end:[s3.js.create_unique_bucket]
github awsdocs / aws-doc-sdk-examples / javascript / example_code / nodegetstarted / sampleV3.js View on Github external
(async function() {
  // Load the S3 client and commands for Node.js
  const {
    S3Client,
    CreateBucketCommand,
    PutObjectCommand
  } = require('@aws-sdk/client-s3')
  
  var uuid = require('uuid')

  // Unique bucket name
  const bucketName = 'node-sdk-sample-' + uuid.v4()
  // Name for uploaded object
  const keyName = 'hello_world.txt'

  const client = new S3Client({})

  const createCommand = new CreateBucketCommand({
    Bucket: bucketName
  })

  const putCommand = new PutObjectCommand({
    Bucket: bucketName,
    Key: keyName,
    Body: 'Hello World!'
  })

  try {
    await client.send(createCommand)
    await client.send(putCommand)
    console.log('Successfully uploaded data to ' + bucketName + '/' + keyName)
  } catch (err) {

@aws-sdk/client-s3

AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native

Apache-2.0
Latest version published 6 days ago

Package Health Score

89 / 100
Full package analysis

Similar packages