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!!!
Hi Robert,
Thanks for your help.
I knew the shapefile woulb be in a zip format for uploading into my account, but i would like to create the zip and upload it into my accound using javascript API for ArcGIS. I don't know how I coulb do it
My idea is there are some boxes where your load the differents files (.shp .shx .dbf .prj) and when I press a button the code create a zip file and upload it into my ESRI account.
Do you Know any documentation to do this ??
Isaac,
There will be no esri documentation on the zipping part as that would be some third party library you would use for that. But uploading programatically, this thread may help.
https://community.esri.com/thread/203227-upload-kml-file-programmatically
Hi Robert,
I had tried understand the link you posted, but I don´t know very well how could upload a shapefile (in a .zip, we forgetting create a zip using js) in my esri account from my application.
Thanks for your help again.
I found a way to add a featureLayer from zip in this link: Create a FeatureLayer from a shapefile | ArcGIS API for JavaScript 4.15
Anyway there is not guide for save my new feature layer in mi esri account
Isaac,
No you will not find any guide or documentation on this subject. The post that I linked is the closet thing you have to guidance. It is use a REST API call to add a file to your AGOL account. In that link you will see Thomas's reply and even a JS function using esriRequest to add a file to your Portal.
Hi,
Very thanks for all your help
The problem is I don`t understand the code from https://community.esri.com/thread/203227-upload-kml-file-programmatically#comment-720547 it is first time I do something like this.
In the page your share there is next code (I think I would be use just this part):
// user is a portalUser.
// fileList is an array of files.
// tags is an array of strings
function addFileaAsPortalItem(user, fileList, tags){
const file = fileList[0];
let form = new FormData();
form.append('file',file);
form.append("f", "json");
form.append("title", file.name);
form.append("name", file.name);
form.append("type",'KML');
form.append("token", <server token>);
form.append("filename", file.name);
form.append("tags", tags.join());
return esriRequest(`${user.userContentUrl}/addItem`,{
method: 'post',
query: form
});
}
What it is portal User ?
If portal user is:
https://www.arcgis.com/sharing/rest/content/users/****/items
What it is *****? my Temporary access token??, my Subscription ID??
What tags are?
should I create this function and It will be work?
Sorry for my javascript level and thanks again for your help
Isaac,
That is the name of your portal userid. Tags are explained in the help docs:
Hello Robert,
Sorry for upseting you.
Could you say me the asnwer to my question, if you know it?
If you could say it step by step I will be very thank you. However, If you do not know the answer just say it and I will stop ask you.
I just want to save a feature layer or shapefile (.zip) in arcgis online from my application.
I tried several ways but I have not found any way to do it
Thanks a lot anyway !!!