We are building a process which will allow users to submit a table of GPS data to update our central repository for all GPS data. Let's say that the target is simply a SQL data table. At first I thought about trying to accomplish this with an SQL INSERT wrapped in a Python script (exposed a GP tool). However, a colleague suggested that we somehow just get the table to the server and let integration services handle the Insert/append to the SQL table.

My question is then, how to create a simple file retrieval service? I'm comfortable with the Python/GP service aspect of ArcGIS server. Basically it would be just the user submitting a table and placing it in a known location on the server.

EDIT: I should add i'm not looking to upload a file from HTTP location; it must allow access to 'local' files on the user's system.

  • any suggestions via python and FTP? Any help before I go slink over to stack overflow? Apr 18, 2013 at 12:28

2 Answers 2


You're approaching this from the wrong angle. You want the file upload to occur within the API in which your app works. Usually (always?) you have to use a aspx/php/other script to accomplish this.

Flex (say...) will present a dialogue box to the user to select the file, then Flex calls an aspx script to move that file from the users computer onto the server temp folder, then returns that (temp/random) path back to the Flex app - which in turn can call a geoProc, passing it the file.

The geoproc can then parse the NMEA sentences (or whatever data you have, CSV, etc) and [do whatever] to write it into SQL/ESRI FC.

I would start by looking up:

1 Your native API and a sample upload file code snippet (they are rampant) eg http://weblog.cahlan.com/2006/09/uploading-files-with-flex-and-php.html

2 A script (aspx or php) to fetch the file. eg http://www.w3schools.com/php/php_file_upload.asp

*1 actually contains a sample for the entire process, but I threw #2 in there for more context.

3 Then write a geoproc (or php still!!) to write to your SQL. (php if you are not writing into an ESRI GDB - for certain! I think this is required actually... Flex can't talk to SQL, if I'm not mistaken - or I've just never done it...)

I find this chained method to be very easy to follow, debug, and customize (control).

Best of luck!

Apologies: I totally missed the EDIT on the end... If your users are local, I would just get python to parse the file line by line and write to SQL directly. No GP Tool, no AGS required. I am missing something?

  • I have to apologize for not including the detail that I would be working with the simple viewers (either Flex or Silverlight), and I struggle with the web development component. The nature of my job is such that I'm wearing many hats and I don't have one area I can focus on. What you're describing sounds like I would be working with the actual API, correct? The GP component in my mind seems easy because I can execute SQL cmds within Python, so getting the table data into the DB is easy, getting the table to the server is the hard part. All web users: by local I mean files on the users system. Apr 22, 2013 at 12:07
  • Np. Can you elaborate on what type of data the SQL is - is it plain text, ie just SQL, or are you spatially enabled? ie PostGIS? If it's just a table of NMEA data from a GPS, you don't really need Arcpy, although it could facilitate arguments. Let me know. I also don't understand - can you distinguish between DB and server? Maybe a quick workflow would be handy to see.
    – Tom
    Apr 22, 2013 at 15:33
  • Not spatially enabled: basically just a table that stores GPS point records, but can be viewed as an event theme. The reason for (MS)SQL is that an index is used and when INSERT is executed we strip out existing/duplicated records before new records are added. There are a variety of reasons (which are hard to expand up on in the limited characters here) but basically exposing the workflow as a GP service has the advantage of using the (Flex) GP widget's ability to upload local (data) files. From there my hope is that since I can execute SQL commands from python, the table can get 'passed' to Apr 22, 2013 at 15:47
  • the SQL commands as an input. Or, possibly the GP service, uploads the table, copies and renames it to a repeated file name (overwrites an existing) and executes a batch file that stores the SQL commands; no input is needed since it executes against the same file (name) and same file location each time. Apr 22, 2013 at 15:51
  • OK, so I've had some success. I exposed a GP service which uses 'Copy Rows' and passes a table to a small python script which simply copies the table to a known location on the server. When published, this works on the desktop end, and also works in Flex Viewer! Unfortunately running into a security issue: when the GP service is secured, I get token issues in the web app. Seems the viewer isn't passing credentials to the GP widget (lame...its ALWAYS a security issue with ESRI). Anyway, now I all i have to do is execute the integration service against the copied table! Apr 22, 2013 at 18:53

Since ArcGIS Server 10.1, there is a way to upload local file to ArcGIS Server in REST API. In this case, you can upload own local file as GPDataFile and use it in your GP Service input. please check the REST API help.

  • Hmm. For some reason the Usage Example isn't working, returns a 500 error. So with this, how do I expose the upload function within the Flex Viewer? Apr 22, 2013 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.