久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 Google Drive Api v3 (javascript) 創(chuàng)建文件

Create File with Google Drive Api v3 (javascript)(使用 Google Drive Api v3 (javascript) 創(chuàng)建文件)
本文介紹了使用 Google Drive Api v3 (javascript) 創(chuàng)建文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想使用 Google Drive API v3 創(chuàng)建一個包含內容的文件.我已通過 OAuth 進行身份驗證并加載了 Drive API.像下面這樣的語句可以工作(但會生成一個沒有內容的文件):

I want to create a file with content using Google Drive API v3. I have authenticated via OAuth and have the Drive API loaded. Statements like the following work (but produce a file without content):

gapi.client.drive.files.create({
    "name": "settings",
}).execute();

不幸的是,我不知道如何創(chuàng)建包含內容的文件.我找不到使用 Drive API v3 的 JavaScript 示例.我需要傳遞一些特殊的參數(shù)嗎?

Unfortunately I cannot figure out how to create a file that has a content. I cannot find a JavaScript example using Drive API v3. Are there some special parameters that I need to pass?

為簡單起見,假設我有一個類似 '{"name":"test"}' 的字符串,它是 JSON 格式,應該是創(chuàng)建文件的內容.

For simplicity, assume that I have a String like '{"name":"test"}' that is in JSON format that should be the content of the created file.

推薦答案

這里是gapi.client.drive的解決方案,

var parentId = '';//some parentId of a folder under which to create the new folder
var fileMetadata = {
  'name' : 'New Folder',
  'mimeType' : 'application/vnd.google-apps.folder',
  'parents': [parentId]
};
gapi.client.drive.files.create({
  resource: fileMetadata,
}).then(function(response) {
  switch(response.status){
    case 200:
      var file = response.result;
      console.log('Created Folder Id: ', file.id);
      break;
    default:
      console.log('Error creating the folder, '+response);
      break;
    }
});

您需要連接/授權以下范圍

https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file

可以通過將 mimeTypeapplication/vnd.google-apps.folder 更改為一個來創(chuàng)建 google 文件(文檔、表格等)支持的 google mime 類型.但是,目前無法將任何內容上傳到創(chuàng)建的文件中.

it is possible to create google files (doc, sheets and so on) by changing the mimeType from application/vnd.google-apps.folder to one of the supported google mime types. HOWEVER, as of now it not possible to upload any content into created files.

要上傳文件,請使用 @Geminus 提供的解決方案.請注意,您可以上傳文本文件或 csv 文件并將其內容類型分別設置為 google doc 或 google sheet,google 將嘗試對其進行轉換.我已經為 text -> doc 測試了這個,它可以工作.

To upload files, use the solution provided by @Geminus. Note you can upload a text file or a csv file and set its content type to google doc or google sheets respectively, and google will attempt to convert it. I have tested this for text -> doc and it works.

這篇關于使用 Google Drive Api v3 (javascript) 創(chuàng)建文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發(fā)出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 亚洲欧美激情精品一区二区 | 免费在线精品视频 | 一区二区不卡高清 | 日韩欧美在线观看视频 | 亚洲久草视频 | 亚洲成人精品一区 | 日本久久精 | 亚洲国产一区二区三区在线观看 | 国产成人精品一区二区三区在线 | 日韩一级免费看 | 91精品国产色综合久久 | 国产精品久久久久久久久久不蜜臀 | 黄色毛片免费 | 午夜欧美a级理论片915影院 | 欧美精品久久久久久久久老牛影院 | 中文字幕在线观看一区 | 国产成人网 | 亚洲欧洲日韩 | 色欧美综合 | 国产一区在线免费 | 天天看天天摸天天操 | 青青草视频免费观看 | www国产成人免费观看视频 | 亚洲中字在线 | 国产精品伦一区二区三级视频 | 国产一区二区在线免费观看 | 欧美日韩精品综合 | 一级欧美一级日韩片 | 男人av的天堂| 亚洲欧美一区二区三区1000 | 国产精品99久久久久久宅男 | 亚洲一区二区三区在线视频 | 三级在线观看 | 玖玖玖在线观看 | 亚洲不卡在线观看 | 91精品国产一区二区三区 | 岛国av免费看 | 亚洲精品久久久久中文字幕二区 | 亚洲免费网 | 亚洲精选久久 | 午夜影院在线免费观看视频 |