You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think for the resumable uploads there is a small difference between the emulated and real GCS for when we start an upload.
The below code snippet is an example of an initial request that we can do to get the current status of the upload. You usually do this to see if there is anything already uploaded.
I would expect to receive a 308 response (upload incomplete), but instead I'm getting a 200 response.
Note that you can skip this step and just directly upload the file, but it would be nice that this would work as expected.
Here is an example to reproduce the issue
# Copyright 2019 Francisco Souza. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# How to run this example
# 1 - Build the docker image by running the command "docker build -t fsouza/fake-gcs-server ."
# 2 - Start the docker container: "docker run -d --name fake-gcs-server -p 4443:4443 -v ${PWD}/examples/data:/data fsouza/fake-gcs-server -scheme http"
# 3 - Check if it's working by running: "curl http://0.0.0.0:4443/storage/v1/b"
# 4 - Create a python virtual enviroment (Ex: python -m .venv venv)
# 5 - Source the env (source .venv/bin/activate)
# 7 - Go to the following directory examples/python: (cd examples/python)
# 6 - Install requirements: "pip install -r requirements.txt" and "pip install -r requirements.in"
# 7 - Run this script
import tempfile
from google.auth.credentials import AnonymousCredentials
from google.cloud import storage
import requests
client = storage.Client(
credentials=AnonymousCredentials(),
project="test",
# This endpoint assumes that you are using the default port 4443 from the container.
# If you are using a different port you need to update this endpoint
client_options={"api_endpoint": "http://localhost:4443"},
)
bucket = client.bucket("sample-bucket")
with tempfile.NamedTemporaryFile(suffix=".html", delete=False) as temp_file:
temp_file.write(b"<html><body><h1>Hello, World!</h1></body></html>")
blob = bucket.blob(temp_file.name)
session_url = blob.create_resumable_upload_session(client=client)
headers = {"Content-Length": "0", "Content-Range": "bytes */*"}
response = requests.put(session_url, headers=headers)
print(response.json())
Hello!
I think for the resumable uploads there is a small difference between the emulated and real GCS for when we start an upload.
The below code snippet is an example of an initial request that we can do to get the current status of the upload. You usually do this to see if there is anything already uploaded.
I would expect to receive a 308 response (upload incomplete), but instead I'm getting a 200 response.
Note that you can skip this step and just directly upload the file, but it would be nice that this would work as expected.
Here is an example to reproduce the issue
This is the response that I got
Running the same example against the real GCS I get the following response:
The text was updated successfully, but these errors were encountered: