Hello everyone
I am making an application using ArcGIS API for JavaScript 4.15.
I would like to be able to have a button by which to upload my shapefile files from my local to my ArcGIS for Developers account, so I can use them later.
I would like doing this using javascript code, but I have not found a example of this.
Thanks!!!
Sorry I do not have a step by step for you.
So, the function should be something like this:
// user is a portalUser.
// fileList is an array of files.
// tags is an array of strings
userid=Subscription ID (the only ID i have from https://igarcia27.maps.arcgis.com/home/organization.html#overview )
file="C:\Users\igarcia\Downloads\myshapefile.zip"
server token= Temporary access token (the only token i have in ArcGIS for Developers )
function addFileaAsPortalItem(tags){
const file = file;
let form = new FormData();
form.append('file',file);
form.append("f", "json");
form.append("title", "myshapefile");
form.append("name", "myshapefile");
form.append("type",'shapefile');
form.append("token", <server token>);
form.append("filename", "myshapefile");
form.append("tags", tags.join());
return esriRequest('https://www.arcgis.com/sharing/rest/content/users/'+userid+'/addItem',{
method: 'post',
query: form
});
}