【问题标题】:Shopify Server not allowing complete file downloadShopify Server 不允许完整的文件下载
【发布时间】:2021-10-14 08:28:42
【问题描述】:

我使用 webpack 编写了一个页面并将其集成到 shopify 商店中。该网站在我的本地服务器上运行良好,但在 shopify 服务器上却不行。

问题出在这部分:

  return fetch(filePath)
// Retrieve its body as ReadableStream
.then(response => response.body)
// Create a gray-scaled PNG stream out of the original
.then(rs => {
  console.log(rs)
  return rs.pipeThrough(
    new TransformStream({
      transform: async (chunk, controller) => {
        try {
          const decryptedChunk = decipher.update(chunk)
          controller.enqueue(decryptedChunk)
        } catch (err) {
          console.error(err)
        }
      }
    })
  )
})
// Create a new response out of the stream
.then(rs => new Response(rs))
// Create an object URL for the response
.then(response => response.blob())
.then(blob => URL.createObjectURL(blob))
// return the URL
.then((responseURL) => { return responseURL })
.catch(console.error)

在我的本地“Windows 10”计算机上运行良好,带有 shopify 主题服务。每个目标文件加载四个块。它在 CentOS 7 服务器上的先前站点版本中也可以正常工作。

将页面推送到shopify服务器时,目标文件未完全加载。只加载一个碎片块,仅此而已。

我尝试过使用 Brave、Chrome、Firefox 和 Edge。所有相同的结果。似乎 fetch 没有下载完整的文件。

更新: 该网址由 shopify 动态计算,类似于“https://cdn.shopify.com/s/files/1/0592/8421/4512/t/1/assets/42a0ee4e462cc7ac412522343.zip”

在本地,文件已使用 fetch 正确加载,并且可以使用提供的链接直接从浏览器下载。

在 shopify 服务器上,提取不起作用。当我尝试从浏览器直接下载时,它会返回一个名称正确的 1ko 文件(而不是 ~100ko)。

【问题讨论】:

  • 它来自 Shopify。链接中的文件权重只有 1Ko。
  • 看来 Shopify 不允许完整下载二进制文件。有办法改变吗?

标签: javascript asynchronous shopify chunks transform-stream


【解决方案1】:

Shopify 只能提供以下格式的文件:

JS CSS 动图 JPG PNG JSON CSV PDF (

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    相关资源
    最近更新 更多