'file' - ArcGIS REST API - For ArcGIS Online

4150
2
10-06-2014 12:29 PM
Drew
by
Occasional Contributor III

Hello,

I am attempting to use the REST API for ArcGIS Online.

I have been successful in adding some general items through code, but I would like to now upload a map package using the API.

I am using the 'AddItem' function and am applying the 'file' parameter in my POST request (I also make it multipart)

What I am wondering what do I pass as a value for the 'file' parameter when trying to upload a file such as a map package?

Do I pass a local path: c:\temp\test.mpk

Do I pass a Base64 string ?

Do I pass some sort of byte array?

I have tried many different methods, but none are working.

Any ideas would be helpful.

Thanks,

Drew

0 Kudos
2 Replies
Drew
by
Occasional Contributor III

I was able to figure this out.. It was not as simple as I expected but it can be done.

Basically I had to create a Multipart Form Post in .NET

There is a nice C# Class someone wrote to assist with this here: Multipart Form Post in C# - Brian Grinstead

Andrew

PaulCrickard1
Occasional Contributor II

In non-GIS file via form, you send a file like this:

<form action="/upload" enctype="multipart/form-data" method="post" accept="image/*;caputre=camera">

<input type="file" name="upload" multiple="multiple"><br>

<input type="submit" value="Upload">

</form>

This is a sample I use for sending images from a computer to the server or opening the camera on a cell phone(so you probably don't need the accept= part unless you want to filter allowed filetype). The server should already be setup to handle the upload.

The link you posted says you can upload a zip or map package

Zip file (*.mpk, *.lpk)
|-- esriinfo (folder)
  |-- iteminfo.xml (item card)
  |-- subfolder
  |-- thumbnail.jpg