AnsweredAssumed Answered

How to Pass File Directly to esriRequest Instead of Using Form Upload

Question asked by behClevest on Aug 3, 2017
Latest reply on Aug 4, 2017 by jgrayson-esristaff

The esriRequest is used for retrieving data from a remote server or uploading a file. The Request has a Form option which is used If the request is to upload a file. We specify the form element that contains the file input control here (As below sample).

request({
    url: portalUrl + '/sharing/rest/content/features/generate',
    content: myContent,
    form: dom.byId('uploadForm'),
    handleAs: 'json',
    load: lang.hitch(this, function (response) {
    if (response.error) {
      errorHandler(response.error);
      return;
    }
    var layerName = response.featureCollection.layers[0].layerDefinition.name;
      addShapefileToMap(response.featureCollection);
    }),
    error: lang.hitch(this, errorHandler)
});

Now, I need to pass a file directly to this options instead of using HTML File Dialog and Input. something like

var data = "www.domain.com/GIS/App.ZIP";
request({
....,
form: data,
....
});

Thanks

Outcomes