Skip to content

Testing the Server

Nimish Agrawal edited this page Oct 16, 2020 · 1 revision

To test the functionalities in the server, I am currently using aws-sdk.

Here is a small snippet of code which I use to test uploading of files

var fs = require('fs')
var AWS = require('aws-sdk')

var config = {
  endpoint: new AWS.Endpoint('http://localhost:3000'),
}

var client = new AWS.S3(config)

// client.createBucket({Bucket: 'bucket1'}, (err,data) => {
//   console.log(err,data);
// })

var params = {
  Key: 'testvideo.mp4',
  Bucket: 'bucket1',
  Body: fs.createReadStream('./testvideo.mp4')
}

client.upload(params, function uploadCallback (err, data) {
  console.log(err, data)
})

Based on the size of the video, aws-sdk automatically does multipart upload or a normal put.

Clone this wiki locally