Skip to content

Commit

Permalink
Fix: initiating resumable upload without metadata (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
oittaa authored Mar 14, 2022
1 parent 4e1173f commit 19a998c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gcp_storage_emulator/handlers/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ def _multipart_upload(request, response, storage):


def _create_resumable_upload(request, response, storage):
object_id = request.data.get("name")
if request.data:
object_id = request.data.get("name")
# Overrides the object metadata's name value, if any.
if "name" in request.query:
object_id = request.query["name"][0]
Expand Down
9 changes: 9 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,15 @@ def test_signed_url_upload_to_nonexistent_bucket(self):
response = requests.put(url, data=file)
self.assertEqual(response.status_code, 404)

def test_initiate_resumable_upload_without_metadata(self):
self._client.create_bucket("test_bucket")
headers = {"Content-type": "application/json"}
response = requests.post(
"http://127.0.0.1:9023/upload/storage/v1/b/test_bucket/o?uploadType=resumable&name=test_file",
headers=headers,
)
self.assertEqual(response.status_code, 200)


class HttpEndpointsTest(ServerBaseCase):
"""Tests for the HTTP endpoints defined by server.HANDLERS."""
Expand Down

0 comments on commit 19a998c

Please sign in to comment.