Question

FMEServer.js - runWorkspaceWithData doesn't work with zipped up shapefiles?

  • 30 March 2016
  • 7 replies
  • 0 views

Badge

Hi there!

I'm trying to use the javascript API for FME Server to let a user upload a shape file and get it processed. Since shape files exist out of more than one file i'm trying to upload those as a zip archive. 

Uploading works perfectly fine. 

Now i need to get my uploaded files with 'FMEServer.getDataUploads' to process them via 'FMEServer.runWorkspaceWithData'. The JSON answer object i get has no property 'file', it has only properties 'archive'. Thats the reason why runWorkspaceWithData gets an error - it builds the rest call together, the property 'file' is undefined so the call looks something like this:

"NetworkError: 422 Unprocessable Entity - <a href="https://ourhost:8443/fmejobsubmitter/A62_BPBW/GEOLINE_ImportFootprint2GDB.fmw?SourceDataset_SHAPE_3=%22%22$%28FME_DATA_REPOSITORY%29/A62_BPBW/GEOLINE_ImportFootprint2GDB.fmw/2EE2C3503B5B292AC477FAA7B31395C5/undefined%22%20%22$%28FME_DATA_REPOSITORY%29/A62_BPBW/GEOLINE_ImportFootprint2GDB.fmw/2EE2C3503B5B292AC477FAA7B31395C5/undefined%22%20%22$%28FME_DATA_REPOSITORY%29/A62_BPBW/GEOLINE_ImportFootprint2GDB.fmw/2EE2C3503B5B292AC477FAA7B31395C5/undefined%22%20%22&Art;=Orthophoto&ID;=1&opt;_responseformat=json&token;=bbb294dbf0efb4ae1f46b83137519bcbfcf47e19&detail;=high"></a>

Can someone help?

Best regards from Stuttgart Germany

Marius Kolleck


7 replies

Badge

I took two screenshots for better understanding:

The first one shows what the function getDataUploads returns, if a zip file has been uploaded,

the second one is the javascript function from the FMEServer.js file wich cycles through the 'files'-array searching for a property 'name'.

Zipfiles are all listed in the child node 'archive', so the for-each loop gets for the 'name' property undefined.

Badge

I stumbled over the fme server developers playground, there's an example how to upload files in a session. 

http://playground.fmeserver.com/javascript/server-uploads/upload-file-in-session/

Even here the problem exists, the dropdown menu "Source Format" offers ESRI Shape, the answer from getDataUploads is similar to mine:

{
    "serviceResponse": {
        "statusInfo": {
            "status": "success"
        },
        "session": "54001B18670924F76B94CB5DF3B3DD80",
        "files": {
            "path": "",
            "folder": [
                {
                    "name": ""
                }
            ],
            "archive": [
                {
                    "size": 10038818,
                    "name": "Webanwendung_LHS_VS.zip"
                }
            ]
        }
    }
}

Trying to "Run Workspace With Data" says, that no file is uploaded if you try a zipped up Shape file. But since there is no posibility to select mulitple files there is no way to upload shape except as a zip.

Badge

Don't know if it will work but try to rename your zip file to .shz

Badge

There's a parameter, you can set for fileuploads, that forces zip files to be unzipped:

opt_extractarchive = true

This parameter can't be set in the FMEServer.js-method uploadData(), it hast to be sent with the HTTP POST or HTTP PUT request to fmedataupload service (in FMEServer.js). I think it's also possible to send this as a parameter in the getSession method.

I myself added following line to the FMEServer.js in the dataUpload method:

params.append('opt_extractarchive', true);

(In my case every uploaded zip shall be unzipped for processing).

Badge

Don't know if it will work but try to rename your zip file to .shz

@larry, thanks for your advice, but just yesterday i got the correct answer from the guys at conterra. See answer below.

Hi Marius,

 

 

I am trying to achieve the same result - to upload zipped shp and run some workspace.

 

Using your suggestion doesn't give any positive result.
params.append('opt_extractarchive', true);

In the debugger i still get a message that i do not have any file:

 

no element found       fileUpload.fmw:1:1

Could you please let me know if your suggestion works for you?

 

Badge

Hey there, sorry for the late response!

For me the solution works, i inserted the parameter another way. I manipulated the original FMEServer.js file, there is a codeline setting the parameters for an ajax call and sending it.

getSession : function(repository, workspace, callback){
callback = callback || null;
        var url = buildURL('{{svr}}/fmedataupload/' + repository + '/' + workspace);
var params = 'opt_extractarchive=true&opt;_pathlevel=3&opt;_fullpath=true&
tm_priority=5&token;=' + getConfig('token');
ajax(url, callback, 'POST', params, 'application/x-www-form-urlencoded');

I also configured my job priority there.

Reply