{"size": 462, "ext": "js", "max_stars_repo_path": "src/lambda/uploadFile.js", "max_stars_repo_name": "d-ivashchuk/mentored", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/lambda/uploadFile.js", "max_issues_repo_name": "d-ivashchuk/mentored", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/lambda/uploadFile.js", "max_forks_repo_name": "d-ivashchuk/mentored", "max_forks_repo_forks_event_min_datetime": "2020-07-23T09:47:26.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-23T09:47:26.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 22.0, "max_line_length": 58, "alphanum_fraction": 0.6645021645}
import s3 from "./digitalOcean"

exports.handler = async (event, context, callback) => {
  const params = JSON.parse(event.body)
  console.log(params.type, params.name)

  const s3Params = {
    Bucket: "mentored",
    Key: params.name,
    ContentType: params.type,
    ACL: "public-read",
  }

  const uploadURL = s3.getSignedUrl("putObject", s3Params)

  return callback(null, {
    statusCode: 200,
    body: JSON.stringify({ uploadURL: uploadURL }),
  })
}
