The image cannot be displayed because it contains errors after uploading with storage-py
FlickNBA opened this issue · comments
Describe the bug
I am trying to upload images to bucket and after it's uploaded it shows this error:
The image cannot be displayed because it contains errors
When I upload manually using browser to the same bucket folder it works.
To Reproduce
Steps to reproduce the behavior:
img_1 = "/Users/FSD/X.jpg"
path_1 = "public/" + img_1.split("/")[-1] # public/X.jpg
headers = {"apiKey": key, "Authorization": f"Bearer {key}"}
storage_client = storage3.create_client(url, headers, is_async=False)
sc = storage_client.get_bucket("bucket")
test1 = sc.upload(path_1, img_1, {"Content-Type": "image/jpeg"})
print(test1.url)
print(sc.get_public_url(path_1))
print(sc.create_signed_url(path_1, 3600))
Expected behavior
I should get working link to image. My bucket is public and I have "policies under storage.buckets" allowing read to everyone. It either shows "this image cannot be displayed because it contains errors" or "authorization 400 error"
After changing policies (updated INSERT privileges) public and signed URLs work but image is corrupted. Weird.
(apologies for the late response)
this is most likely because the header is expected to be in all lower case by the api (content-type
instead of Content-Type
)