"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchAndUploadResource = fetchAndUploadResource;
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
const fetch_image_as_blob_1 = require("./fetch-image-as-blob");
/**
 * Fetch image from a url, and upload as a resource
 * @param {Object} options {id, owner, fileName, url, authentication}
 */
function fetchAndUploadResource(options) {
    // first fetch it as a blob...
    return (0, fetch_image_as_blob_1.fetchImageAsBlob)(options.url).then((file) => {
        // upload it to the item...
        return (0, arcgis_rest_portal_1.addItemResource)({
            id: options.id,
            owner: options.owner,
            name: options.fileName,
            resource: file,
            authentication: options.authentication,
        });
    });
}
//# sourceMappingURL=fetch-and-upload-resource.js.map