I'm using GoogleApi.Storage.V1.Api.Objects.storage_objects_insert_simple to upload files to Google Storage. However, it seems that no matter what I do, the content-disposition
HTTP response header is being set to attachment
which forces browsers to download a file rather than displaying it in a browser tab.
Here's my usage:
{:ok, object} =
GoogleApi.Storage.V1.Api.Objects.storage_objects_insert_simple(
gconn,
"my-uploads-bucket",
"multipart",
%{
name: Path.basename(path),
contentType: content_type,
contentDisposition: "inline" # <-- this doesn't seem to have an effect
},
path
)
Does anyone know how to force the content disposition header to have a value of inline
?
Update
After inspecting the value of object
, I'm seeing the following:
%GoogleApi.Storage.V1.Model.Object{
acl: nil,
bucket: "my-uploads-bucket",
cacheControl: nil,
componentCount: nil,
contentDisposition: "inline", # <-- !!!
contentEncoding: nil,
contentLanguage: nil,
contentType: "image/png",
crc32c: "MGa01Q==",
...
However, after fetching a file via curl -I <url>
, I see the following:
HTTP/2 200
...
content-type: image/png
content-disposition: attachment
...
question from:
https://stackoverflow.com/questions/65838239/how-to-force-google-storage-file-to-have-content-disposition-inline-instead-o 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…