UNPKG

mongodb-stitch

Version:

[![Join the chat at https://gitter.im/mongodb/stitch](https://badges.gitter.im/mongodb/stitch.svg)](https://gitter.im/mongodb/stitch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

74 lines (61 loc) 2.78 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _util = require('../../util'); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Convenience wrapper around AWS S3 service (not meant to be instantiated directly, * use `.service('aws-s3', '<service-name>')` on a {@link StitchClient} instance). * * @class * @return {S3Service} a S3Service instance. */ var S3Service = function () { function S3Service(stitchClient, serviceName) { _classCallCheck(this, S3Service); this.client = stitchClient; this.serviceName = serviceName; } /** * Put an object to S3 via Stitch. For small uploads * * @param {String} bucket which S3 bucket to use * @param {String} key which key (filename) to use * @param {String} acl which policy to apply * @param {String} contentType content type of uploaded data * @param {String|BSON.Binary} body the content to put in the bucket * @return {Promise} which resolves to an object containing a single field "location" * which is the URL of the object that was put into the S3 bucket */ _createClass(S3Service, [{ key: 'put', value: function put(bucket, key, acl, contentType, body) { return (0, _util.serviceResponse)(this, { action: 'put', args: { bucket: bucket, key: key, acl: acl, contentType: contentType, body: body } }); } /** * Sign a policy for putting via Stitch. For large uploads * * @param {String} bucket which S3 bucket to use * @param {String} key which key (filename) to use * @param {String} acl which policy to apply * @param {String} contentType content type of uploaded data * @return {Promise} */ }, { key: 'signPolicy', value: function signPolicy(bucket, key, acl, contentType) { return (0, _util.serviceResponse)(this, { action: 'signPolicy', args: { bucket: bucket, key: key, acl: acl, contentType: contentType } }); } }]); return S3Service; }(); exports.default = S3Service; module.exports = exports['default'];