import { updateItem } from "../rest/portal/wrappers";
import { fetchImageAsBlob } from "./fetch-image-as-blob";
/**
 * Fetch image from a url, then upload to an item as it's thumbnail
 * @param {object} options
 */
export function fetchAndUploadThumbnail(options) {
    // first fetch it as a blob...
    return fetchImageAsBlob(options.url)
        .then((file) => {
        return updateItem({
            item: {
                id: options.id,
                owner: options.owner,
            },
            params: {
                fileName: options.fileName,
                thumbnail: file,
            },
            authentication: options.authentication,
        }).catch((_) => {
            // resolve b/c this is not crtical
            return Promise.resolve();
        });
    })
        .catch((_) => {
        return Promise.resolve();
    });
}
//# sourceMappingURL=fetch-and-upload-thumbnail.js.map