UNPKG

react-web-native-sketch

Version:

[TODO: We need an overview of how this can be used via npm vs as a local package]

31 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var common_1 = require("./common"); var __1 = require("../.."); function onDrop(acceptedFiles, rejectedFiles, props) { var field = props.field, lastPhotoIndex = props.lastPhotoIndex, multiple = props.multiple, postPhotoToS3 = props.postPhotoToS3, showAlert = props.showAlert, t = props.t, minWidth = props.minWidth, maxWidth = props.maxWidth, minHeight = props.minHeight, maxHeight = props.maxHeight, fixedWidth = props.fixedWidth, fixedHeight = props.fixedHeight, ratioWidthHeight = props.ratioWidthHeight; var file = acceptedFiles[0]; var _URL = window.URL || window.webkitURL; if (!file.type.match('image.*')) { showAlert(__1.FILE_IS_NOT_IMAGE); return; } var img = new Image(); img.onload = function () { if (common_1.checkImageRestrictions(showAlert, t, img.width, img.height, minWidth, maxWidth, minHeight, maxHeight, fixedWidth, fixedHeight, ratioWidthHeight)) { var fieldData = { field: multiple ? field + "," + lastPhotoIndex + ".url" : field, url: 'get_s3_upload_params', s3ExtraData: common_1.getPhotoDetails({ rawValue: file }), preview: common_1.getImageUrl(common_1.getImagePreview({ rawValue: file })) }; postPhotoToS3(fieldData); } }; img.onerror = function () { showAlert(__1.FILE_IS_NOT_IMAGE, {}, t(__1.FILE_IS_NOT_IMAGE)); }; img.src = _URL.createObjectURL(file); } exports.onDrop = onDrop; //# sourceMappingURL=uploadUtils.js.map