Page MenuHomePhabricator

Rewrite mw.FormDataTransport.js to make use of mw.Api
Closed, ResolvedPublic

Description

This whole transport mode is currently not using mw.Api, but directly using a XHR. This is unfortunate, because it means it cannot use mw.Api's postWithToken badtoken recovery for instance.

The reason for this implementation was probably because we initially were not able to make this working with jQuery ajax or mw.Api

But I think that:
api.postWithEditToken( {}, {

data: formData,
contentType: false,
processData: false

} )

Then in api.post() we can look for data in the ajaxoptions, do a 'instanceof FormData' check, and then iterate over the params object, and do formData.append( key, value ); (and possibly set the contentType and processData options automatically here).

https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Api-method-postWithToken
https://coderwall.com/p/p-n7eq/file-uploads-with-jquery-html5-and-formdata

Event Timeline

TheDJ raised the priority of this task from to Needs Triage.
TheDJ updated the task description. (Show Details)
TheDJ added a project: UploadWizard.
TheDJ subscribed.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 328371 had a related patch set uploaded (by Matthias Mullie):
Use mw.Api instead of XMLHttpRequest

https://gerrit.wikimedia.org/r/328371

Change 328371 merged by jenkins-bot:
Use mw.Api instead of XMLHttpRequest

https://gerrit.wikimedia.org/r/328371