'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; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var FileUploader = exports.FileUploader = function () {
    function FileUploader() {
        _classCallCheck(this, FileUploader);
    }

    _createClass(FileUploader, null, [{
        key: 'uploadFile',

        // static async uploadImageBase64(mimeType, fileBase64Data) {
        //   const data = new FormData();
        //   data.append(
        //     'image',
        //     `data:${mimeType};base64,${encodeURIComponent(fileBase64Data)}`,
        //   );

        //   const resposne = await fetch(api.upload.base64, {
        //     method: 'POST',
        //     body: data,
        //   });
        //   const json = await resposne.json();
        //   console.log('image uploaded ' +` ${api.s3Url}/${json.bucketPath}`);
        //   return `${api.s3Url}/${json.bucketPath}`;
        // }

        // convertDataURIToBinary(dataURI) {
        //   var BASE64_MARKER = ';base64,';
        //   var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
        //   var base64 = dataURI.substring(base64Index);
        //   var raw = window.atob(base64);
        //   var rawLength = raw.length;
        //   var array = new Uint8Array(new ArrayBuffer(rawLength));

        //   for (let i = 0; i < rawLength; i++) {
        //     array[i] = raw.charCodeAt(i);
        //   }
        //   return array;
        // }
        value: function uploadFile(url, data, callback) {

            fetch('https://dev.api.artishok.io/upload-microservice/upload', {
                method: 'POST',
                body: data
            }).then(function (resp) {

                callback(resp);
            }).catch(function (err) {
                console.log("file upload err : ", err);
                callback(err);
            });
        }
    }]);

    return FileUploader;
}();