rest - Post large files to heroku with Python -


i'm creating python script post audio files api. it's working; however, application on heroku , large files seem getting nabbed heroku's memory limit. tried using multipart/form-data, seems that's not enough. i'm getting 503 errors on 5 minutes.

import requests import os import glob requests_toolbelt import multipartencoder  token = 'xxxx' headers = {'authorization': 'bearer ' + token, 'content-type': 'application/json'} base_url = 'https://test.com/api/'  file in glob.glob("*.mp3"):     files = multipartencoder(fields={'file': (file, open(file, "rb"), 'audio/mpeg')})     audio_headers = {'authorization': 'bearer ' + token, 'content-type': files.content_type}     add_file = requests.post(base_url, headers=audio_headers, data=files) 

heroku has 30 second limit requests. larger files exceed period , request times out. solution post 3rd party storage directly browser (e.g. amazon s3), , send request heroku location of uploaded data. using background process you'll able download file , process want.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -