UNPKG

@esri/solution-common

Version:

Provides general helper functions for @esri/solution.js.

48 lines 1.9 kB
/** @license * Copyright 2018 Esri * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ArcGISAuthError, updateItemResource } from "../arcgisRestJS"; /** * Adds a text resource. * * @param content Text to add as a resource * @param itemId Id of the item to add the resource to * @param folder A prefix string added to the filename in the storage; use null or undefined for no folder * @param filename File name used to rename an existing file resource uploaded, or to be used together with * text as file name for it. File name must have the file resource extension. * @param authentication Credentials for the request */ export function updateTextResource(content, itemId, folder, filename, authentication) { // Check that the filename has an extension because it is required by the addResources call if (filename && filename.indexOf(".") < 0) { return new Promise((resolve, reject) => { reject(new ArcGISAuthError("Filename must have an extension indicating its type")); }); } const requestOptions = { id: itemId, content, name: filename, authentication: authentication, params: {}, }; if (folder) { requestOptions.params = { resourcesPrefix: folder, }; } return updateItemResource(requestOptions); } //# sourceMappingURL=update-resource.js.map