Here is a JavaScript $ dojo sample I created which uploads a json file. It is small json file created dynamically on the client side. You would send your token in the content object if you had one.
var myJson = JSON.stringify(this._serializeGraphics({myProp: myVal}));
var blob = new Blob([myJson], { type: "application/json" });
var formNode = put("form", {
"method": "post",
"enctype": "multipart/form-data"
});
var formData = new FormData(formNode);
formData.append("itemType", "file");
formData.append("type", "GeoJson");
formData.append("title", this.title);
formData.append("file", blob, this.filename);
var path = "content/users/" + this.portalUser.username + '/' + folder + "/addItem";
return esriRequest({
url: this.portal.portalUrl + path,
form: formData,
content: {
f: "json"
}
}, { usePost: true }).then(this._saveSuccessful, this._error);
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.