Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 172a78c

Browse files
Jay-flowhassiebp
andauthored
fix: resolve GCS bad request error in media uploads. (#1265)
Co-authored-by: Hassieb Pakzad <[email protected]>
1 parent 17a7bc1 commit 172a78c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎langfuse/_task_manager/media_manager.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,20 @@ def _process_upload_media_job(
246246

247247
return
248248

249+
headers = {"Content-Type": data["content_type"]}
250+
251+
# In self-hosted setups with GCP, do not add unsupported headers that fail the upload
252+
is_self_hosted_gcs_bucket = "storage.googleapis.com" in upload_url
253+
254+
if not is_self_hosted_gcs_bucket:
255+
headers["x-ms-blob-type"] = "BlockBlob"
256+
headers["x-amz-checksum-sha256"] = data["content_sha256_hash"]
257+
249258
upload_start_time = time.time()
250259
upload_response = self._request_with_backoff(
251260
requests.put,
252261
upload_url,
253-
headers={
254-
"Content-Type": data["content_type"],
255-
"x-amz-checksum-sha256": data["content_sha256_hash"],
256-
"x-ms-blob-type": "BlockBlob",
257-
},
262+
headers=headers,
258263
data=data["content_bytes"],
259264
)
260265
upload_time_ms = int((time.time() - upload_start_time) * 1000)

0 commit comments

Comments
 (0)