summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Copeland <ben.copeland@linaro.org>2018-01-15 17:16:05 +0000
committerBen Copeland <ben.copeland@linaro.org>2018-01-15 17:20:40 +0000
commita02a906b1770a7d39bbe8d456e78b849374636f9 (patch)
tree7a5c679a566715e4b3324750f173a3057dd7a1c6
parent3ae248b714b5f7276b7136b6f0638ef04f543feb (diff)
downloadpublishing-api-a02a906b1770a7d39bbe8d456e78b849374636f9.tar.gz
0 byte: This fixes the 0 byte upload issue
When a 0 byte file gets uploaded, we get a returned message from S3 "501 Not Implemented". This is caused my a bug in the requests library, https://github.com/requests/requests/issues/1648 . By using a different method instead the requests put causes the file to upload because it does not set "Transfer-Encoding: chunked" Change-Id: Ibbd2282dcd37706b67f8b255fd4cce8ef00a6174
-rwxr-xr-xlinaro-cp.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/linaro-cp.py b/linaro-cp.py
index 7292c03..9888d2b 100755
--- a/linaro-cp.py
+++ b/linaro-cp.py
@@ -145,7 +145,12 @@ class API_v3(API_v1):
try:
with open(filename, 'rb') as f:
print("Uploading file %s" % filename)
- resp = requests.put(url, headers=headers, data=f, timeout=61)
+ if size == 0:
+ # Due to a request bug we need to use files system call
+ # to get around https://github.com/requests/requests/issues/1648
+ resp = requests.put(url, headers=headers, files=f, timeout=61)
+ else:
+ resp = requests.put(url, headers=headers, data=f, timeout=61)
if resp.status_code in (200, 201):
return
else: