簡體   English   中英

如何使用谷歌應用程序腳本使用 url 將音頻文件上傳到谷歌驅動器

[英]how to upload audio file to google drive with url with google apps script

有人可以指出我哪里出錯了。 我正在嘗試使用 Google 應用腳本將音頻文件上傳到我的 Google 驅動器。 文件上傳,但我無法播放。

這是我的 function:

function upload() {
    
  var url = 'https://api.twilio.com/2010-04-01/Accounts/ACxxxxxxxxxxxxxx/Recordings/RExxxxxxxxxxxxxxx';
  
    var blob = UrlFetchApp.fetch(url).getBlob().getBytes();

  var folder = DriveApp.getFolderById('xxxxxxxxxxxxxxx');  
  blob = Utilities.newBlob(blob, 'audio/x-wav', 'testFile.wav');
  var file = folder.createFile(blob); 
}

這里的問題不在於您使用的代碼片段 - 因為文件確實已正確上傳,但與瀏覽器和第三方 cookies 相關。

為了播放音頻,應為您的瀏覽器啟用第三方 cookies,因為 Google Drive 無法自行播放文件。

另一種選擇是簡單地選擇谷歌建議的第三方應用程序之一來播放音頻文件。

在此處輸入圖像描述

暫無
暫無

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

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