如何强制 Google 存储文件具有 `content-disposition: inline` 而不是 `attachment`?

How to force Google Storage file to have `content-disposition: inline` instead of `attachment`?

我正在使用 GoogleApi.Storage.V1.Api.Objects.storage_objects_insert_simple 将文件上传到 Google 存储。但是,似乎无论我做什么,content-disposition HTTP 响应 header 都被设置为 attachment,这会强制浏览器下载文件而不是在浏览器选项卡中显示它。

这是我的用法:

{: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
  )

有谁知道如何强制内容配置 header 的值为 inline

更新

检查 object 的值后,我看到以下内容:

%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==",
  ...

但是,通过 curl -I <url> 获取文件后,我看到以下内容:

HTTP/2 200 
...
content-type: image/png
content-disposition: attachment
...

看来我的错误是将 mediaLink 字段用作 URL。此 URL 甚至已作为 URL 的一部分进行下载:https://storage.googleapis.com/download/storage/....

如果我改为使用名称字段来构建 URL,那么它会按预期工作。

send_resp(
  conn,
  200,
  "https://storage.googleapis.com/my-bucket/" <> object.name
)