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 created this task.Mar 26 2015, 9:21 PM
TheDJ raised the priority of this task from to Needs Triage.
TheDJ updated the task description. (Show Details)
TheDJ added a project: UploadWizard.
TheDJ added a subscriber: TheDJ.
Restricted Application added a project: Multimedia. · View Herald TranscriptMar 26 2015, 9:21 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Aklapper set Security to None.
Restricted Application added subscribers: Steinsplitter, Matanya. · View Herald TranscriptJul 29 2015, 5:07 PM
Jdforrester-WMF triaged this task as Low priority.Sep 4 2015, 6:56 PM
Jdforrester-WMF moved this task from Untriaged to Backlog on the Multimedia board.Sep 4 2015, 7:02 PM
Sn1per added a subscriber: Sn1per.Aug 8 2016, 1:34 AM

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

matmarex closed this task as Resolved.Dec 27 2016, 11:10 PM
matmarex removed a project: Patch-For-Review.