2

We use ArcGIS JS API Editor which in turn uses esri.dijit.editing.AttachmentEditor to edit feature attributes and attachments in web browser. However adding attachment (file upload) doesn't work in Chrome and Firefox. A post is made to REST endpoint addAttachment of feature service, with request header Content-Type:text/plain;charset=UTF-8 , and body consisting of serialized DOM tree like:

0=%5Bobject%20HTMLInputElement%5D&sizzle-1491811182682=%5Bobject%20Object%5D&acceptCharset=&action=&autocomplete=on&enctype=application%2Fx-www-form-urlencoded& ...

This fails displaying in error log:

SyntaxError: Unexpected token <
    at Object.b.fromJson (init.js:220)
    at Object.json (init.js:177)
    at s (init.js:182)
    at c (init.js:66)
    at d (init.js:66)
    at b.Deferred.resolve.callback (init.js:67)

Also a string fjson is displayed just below "Choose File" button.

In Edge upload attached file send POST request with correct header, e.g. Content-Type: multipart/form-data; boundary=---------------------------7e1d26607d4 and works correctly.

Actually the same issue exists in ArcGIS Server Manager with upload elements (like Publish service). They don't work in Crome. So I believe there is some issue with dojo library.

Has someone found a workaround for this issue?

(Arcgis js api 3.18)

2

Here is what I found: If FeatureLayer.addAttachment() finds a method append() in HTMLForm (Chrome, FFox, but not IE, Edge) it fails to upload attachement (wrong content type, wrong data).

The hack is to wrap FeatureLayer.prototype.addAttachment to hide append method of form (passed as parameter) before call to original method and restore it afterwards.

API doc for addAttachment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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