Last modified: 2010-01-14 18:24:34 UTC
At test wiki I'm playing around with the upload api. Test wiki is running 1.16alpha-wmf (r57490) at the moment. First I tried using upload by url through the normal upload interface. That works just fine. Now I'm trying to use upload by url in the api to upload some files, but I get an internal_api_error_MWException I run the following piece of python code: def api_upload_image(self, debug=False): """ Use the upload api to upload the image """ #Hacking around to see how the upload api works #First get an edit token params1 = { 'action' : 'query', 'prop' : 'info', 'intoken' : 'edit', 'titles' : self.useFilename } data1 = query.GetData(params1, self.targetSite, useAPI = True, encodeTitle = False) token = data1[u'query'][u'pages']['-1'][u'edittoken'] print token #token = self.targetSite.getToken() #Should do some filename checking #Post all the data to upload the file params2 = { 'action' : 'upload', 'filename' : self.useFilename, 'comment' : self.description, #'token' : 'bladiebla', 'token' : token, #'watch' : '0' #'ignorewarnings' : #'file' : file contents #'enablechunks' #'chunksessionkey', #'chunk' #'done' 'url' : self.url, 'asyncdownload' : 0, #'httpstatus' #'sessionkey' } print params2 data2 = query.GetData(params2, self.targetSite, useAPI = True, encodeTitle = False) print data2 session_key = data2[u'upload']['upload_session_key'] #See the status of the upload params3 = { 'action' : 'upload', #'filename' : self.useFilename, #'comment' : self.description, 'token' : token, #'watch' : '0' #'ignorewarnings' : #'file' : file contents #'enablechunks' #'chunksessionkey', #'chunk' #'done' #'url' : self.url, #'httpstatus' 'sessionkey' : session_key } data3 = query.GetData(params3, self.targetSite, useAPI = True, encodeTitle = False) print data3 The output: # Edit token: 840b5c209660523709ecf8c0bfc06388+\ # Params2: {'comment': u'\ufeff{{Information\n|Description=\xa9 Rubenstein, photographer Ma rtyna Borkowski \n|Source=[http://www.flickr.com/photos/23357263@N03/2679181929/ Rubenstein Staff]\n|Date=2008-07-15 12:12\n|Author=[http://www.flickr.com/peopl e/23357263@N03 Rubenstein] \n|Permission=\n|other_versions=\n}}\n\n=={{int:licen se}}==\n{{cc-by-2.0}}\n{{flickrreview|Multichill|{{subst:CURRENTYEAR}}-{{subst:C URRENTMONTH}}-{{subst:CURRENTDAY2}}}}\n{{subst:unc}}', 'url': 'http://farm4.stat ic.flickr.com/3040/2679181929_a677cd72d4_o.jpg', 'filename': u'Flickr - Rubenste in - Rubenstein_Staff.jpg', 'token': u'840b5c209660523709ecf8c0bfc06388+\\', 'ac tion': 'upload', 'asyncdownload': 0} #data2: {u'upload': {u'upload_session_key': 1555467596}} #data3: {u'error': {u'info': u'Exception Caught: FSRepo::resolveVirtualUrl: unknown protoocl', u'*': u"\n\n #0 /home/wikipedia/common/wmf-deployment/includes/upload/UploadFromStash.php(40): FSRepo->resolveVirtualUrl(NULL)\n #1 /home/wikipedia/common/wmf-deployment/includes/api/ApiUpload.php(119): UploadFromStash->initialize(NULL, Array)\n #2 /home/wikipedia/common/wmf-deployment/includes/api/ApiMain.php(428): ApiUpload->execute()\n #3 /home/wikipedia/common/wmf-deployment/includes/api/ApiMain.php(248): ApiMain->executeAction()\n #4 /home/wikipedia/common/wmf-deployment/includes/api/ApiMain.php(232): ApiMain->executeActionWithErrorHandling()\n #5/home/wikipedia/common/wmf-deployment/api.php(116): ApiMain->execute()\n #6 /usr/local/apache/common-local/live-1.5/api.php(3): require('/home/wikipedia...')\n #7 {main}\n\n", u'code': u'internal_api_error_MWException'}} Might be related to r1=56438&r2=56557&pathrev=57490">http://svn.wikimedia.org/viewvc/mediawiki/branches/wmf-deployment/includes/upload/UploadFromStash.php?r1=56438&r2=56557&pathrev=57490
When I set 'httpstatus' to '1', I won't get this error. Nothing gets uploaded though. Just loops: {u'upload': {u'content_length': u'2288025', u'loaded': 0, u'upload_session_key': u'1327228680'}} {u'upload': {u'content_length': u'2288025', u'loaded': 0, u'upload_session_key': u'1327228680'}} {u'upload': {u'content_length': u'2288025', u'loaded': 0, u'upload_session_key': u'1327228680'}} (etc etc)
yea...btongminh fix for slashed uploads seems to have broken http uploads. Should be fixed in r57535
on second look... its still broke on test.wikimedia.org (after update) yet working locally... hmm...
Is this fixed for sure? If yes, should be resolved as FIXED. If not, should remain open. Leaving as RESOLVED->REMIND hides it from open bug searches.
yea this issue has long since been fixed in trunk / js2-work branch. ( was working "tests" with test.wikipedia.org / commons when upload-by-url was on. )