簡體   English   中英

如何從公共 url 獲取原始圖像?

[英]How to get raw image from a public url?

我試圖在節點中使用 Google Drive API 托管圖像。

await drive.files.create({
  requestBody: {
    role: "render",
    type: "anyone",
  },
});

const response = await drive.files.get({
  fileId: "...",
  fields: "webViewLink, webContentLink",
});

console.log(response.data);

我得到了一個圖片的公共鏈接,我可以在 Google Drive 中打開或下載該圖片以便手動查看。

{
  webContentLink: 'https://drive.google.com/uc?id=1dffGf_4R5W75xKGhx7n-nXsZPFA7NE1a&export=download',
  webViewLink: 'https://drive.google.com/file/d/1dffGf_4R5W75xKGhx7n-nXsZPFA7NE1a/view?usp=drivesdk' 
}

但這不是我想要的。

我希望公共圖像采用原始格式(jpg、png 等),並且應該能夠像瀏覽器中的網站一樣正常查看。

我希望我已經解釋得足夠多了,任何幫助都非常感謝:)

我只是發現,而不是這個......

https://drive.google.com/file/d/1-x3h_1lYrBat7K43LaiTlS9FqQttbbFW/view?usp=sharing

我可以傳遞縮略圖,然后是這樣的file id ......

https://drive.google.com/thumbnail?id=1-x3h_1lYrBat7K43LaiTlS9FqQttbbFW

這很好用,可以嵌入到img標簽的src屬性中......( 來源)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM