Created
December 5, 2016 13:36
-
-
Save trolleway/4e0247288d416d1abbda03b02bc787a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import urllib2 | |
ngw_root = 'http://trolleway.nextgis.com' | |
ngw_creds = ('', '') | |
headers = {'Content-type': 'application/x-www-form-urlencoded'} | |
payload = {'file':urllib2.urlopen('http://trolleway.nextgis.com/api/resource/826/feature/5/attachment/37/image'),'name':'filename.jpg'} | |
print 'Upload attachment to ' + ngw_root + '/api/component/file_upload/upload' | |
req = requests.post(ngw_root + '/api/component/file_upload/upload', data=payload, auth=ngw_creds, headers=headers) | |
print req.status_code | |
print req.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Вот так работает
with closing(requests.get(url_src + str(item['id']) + '/attachment/' + str(attachment_id) + '/download', auth=creds_src, stream=True)) as f:
req = requests.put(url_dst + '/component/file_upload/upload', data=f, auth=creds_dst)