I'm trying to upload a file to Google cloud storage Bucket using Python.It was working fine before but suddenly returning an error.
Here's my code:
from views.py:
def perform_upload(video, thumbnail):
print('vdieo name is: {}'.format(video))
servise = discovery.build('storage', 'v1', credentials=credentials)
bucket_name = 'test_bucket004'
print('Uploading the video...')
media = MediaFileUpload(video, chunksize=4149304, mimetype='video/mp4',
resumable=True)
req = servise.objects().insert(
bucket=bucket_name,
name=str(video),
media_body=media,
body={"cacheControl": "public,max-age=31536000"},
predefinedAcl='publicRead'
)
resp = None
while resp is None:
status, resp = req.next_chunk()
print(resp)
Here's what it returns:
BrokenPipeError: [Errno 32] Broken pipe
[22/Sep/2018 04:56:50] "POST /api/convert/ HTTP/1.1" 500 15981
and Traceback pointing to this line:
status, resp = req.next_chunk()
What can be wrong? How can I resolve this Broken pipe error?
Thanks in advance!
This happens when your network connection (and thus, your connection to GCS) is unstable for some reason. I would recommend retrying this from an environment with a more stable internet connection (switching to a wired connection from wifi, removing an intermediate proxies or firewalls, etc).