本文介绍了编写一个谷歌应用程序脚本,以便将来自URL的PDF存储在谷歌驱动器中的特定文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,这是我想要做的:
我有一个PDF文档的URL。我想将它直接存储到我的谷歌驱动器中,而不是先将它下载到我的硬盘驱动器,然后上传到谷歌驱动器。有谁知道如何做到这一点?
在此先感谢!!!

So here is what I want to do:I have a URL of a PDF document. I want to store it directly into my google drive without downloading it to my hard drive first and then uploading to google drive. Does anyone know how to do this?Thanks in advance!!!

推荐答案

使用urlFetch和DocsList,这非常简单,只需要3行代码:

Using urlFetch and DocsList, this is pretty straightforward and takes only 3 lines of code :

var urlOfThePdf = 'http://www.fostexinternational.com/docs/tech_support/pdfs/280_owners_manual.pdf';// an example of online pdf file
var folderName = 'GAS';// an example of folder name

function saveInDriveFolder(){
  var folder = DocsList.getFolder(folderName);// get the folde
  var file = UrlFetchApp.fetch(urlOfThePdf); // get the file content as blob 
  folder.createFile(file);//create the file directly in the folder
}

这篇关于编写一个谷歌应用程序脚本,以便将来自URL的PDF存储在谷歌驱动器中的特定文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 02:37