How to use the @aws-amplify/storage.put function in @aws-amplify/storage

To help you get started, we’ve selected a few @aws-amplify/storage 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 aws-amplify / amplify-js / packages / aws-amplify-react / src / Storage / S3Text.js View on Github external
load() {
        const { path, textKey, body, contentType, level, track } = this.props;
        if (!textKey && !path) {
            logger.debug('empty textKey and path');
            return ;
        }

        const that = this;
        const key = textKey || path;
        logger.debug('loading ' + key + '...');
        if (body) {
            const type = contentType || 'text/*';
            if (!Storage || typeof Storage.put !== 'function') {
                throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
            }
            const ret = Storage.put(key, body, {
                contentType: type,
                level: level? level : 'public',
                track
            });
            ret.then(data => {
                logger.debug(data);
                that.getText(key, level, track);
            })
            .catch(err => logger.debug(err));
        } else {
            that.getText(key, level, track);
        }
    }
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Storage / S3Image.js View on Github external
load() {
        const { imgKey, path, body, contentType, level, track } = this.props;
        if (!imgKey && !path) {
            logger.debug('empty imgKey and path');
            return ;
        }

        const that = this;
        const key = imgKey || path;
        logger.debug('loading ' + key + '...');
        if (body) {
            const type = contentType || 'binary/octet-stream';
            if (!Storage || typeof Storage.put !== 'function') {
                throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
            }
            const ret = Storage.put(key, body, {
                contentType: type,
                level: level? level : 'public',
                track
            });
            ret.then(data => {
                logger.debug(data);
                that.getImageSource(key, level, track);
            })
            .catch(err => logger.debug(err));
        } else {
            that.getImageSource(key, level, track);
        }
    }
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Storage / S3Text.js View on Github external
handlePick(data) {
        const that = this;

        const path = this.props.path || '';
        const { textKey, level, fileToKey, track } = this.props;
        const { file, name, size, type } = data;
        const key = textKey || (path + calcKey(data, fileToKey));
        if (!Storage || typeof Storage.put !== 'function') {
            throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
        }
        Storage.put(key, file, {
            level: level? level: 'public',
            contentType: type,
            track
        })
            .then(data => {
                logger.debug('handle pick data', data);
                that.getText(key, level, track);
            })
            .catch(err => logger.debug('handle pick error', err));
    }
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Storage / S3Image.js View on Github external
handlePick(data) {
        const that = this;

        const path = this.props.path || '';
        const { imgKey, level, fileToKey, track } = this.props;
        const { file, name, size, type } = data;
        const key = imgKey || (path + calcKey(data, fileToKey));
        if (!Storage || typeof Storage.put !== 'function') {
            throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
        }
        Storage.put(key, file, { 
            level: level? level: 'public',
            contentType: type, 
            track 
        })
            .then(data => {
                logger.debug('handle pick data', data);
                that.getImageSource(key, level, track);
            })
            .catch(err => logger.debug('handle pick error', err));
    }
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Storage / S3Album.js View on Github external
handlePick(data) {
        const that = this;
        const { onPick, onLoad, onError, track, level } = this.props;

        if (onPick) { onPick(data); }

        const path = this.props.path || '';
        const { file, name, size, type } = data;
        const key = path + this.getKey(data);
        if (!Storage || typeof Storage.put !== 'function') {
            throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
        }

        Storage.put(key, file, {
            level: level? level: 'public',
            contentType: type,
            track
        })
            .then(data => {
                logger.debug('handle pick data', data);
                const { items } = this.state;
                if (items.filter(item => item.key === key).length === 0) {
                    const list = items.concat(data);
                    this.marshal(list);
                } else {
                    logger.debug('update an item');
                }
                if (onLoad) { onLoad(data); }
            })
            .catch(err => {

@aws-amplify/storage

Storage category of aws-amplify

Apache-2.0
Latest version published 3 days ago

Package Health Score

92 / 100
Full package analysis

Similar packages