久久久久久久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)建文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

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

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)建包含內(nèi)容的文件.我找不到使用 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?

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

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;
    }
});

您需要連接/授權(quán)以下范圍

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

可以通過將 mimeTypeapplication/vnd.google-apps.folder 更改為一個來創(chuàng)建 google 文件(文檔、表格等)支持的 google mime 類型.但是,目前無法將任何內(nèi)容上傳到創(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 文件并將其內(nèi)容類型分別設(shè)置為 google doc 或 google sheet,google 將嘗試對其進(jìn)行轉(zhuǎn)換.我已經(jīng)為 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.

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

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

相關(guā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(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時的歡迎消息)
主站蜘蛛池模板: 中文字幕成人av | 日本黄色大片免费 | 国产精品一区二区免费 | 欧美日韩在线不卡 | 亚洲免费一区二区 | 国产一区影院 | 色综合视频 | 欧美一区二区 | 日韩精品在线免费 | 欧美精品一区二区三区在线 | 日本在线视频不卡 | av在线免费观看网址 | 国产乱码精品一区二区三区中文 | 亚洲高清在线观看 | 久草网址 | 欧美日韩国产精品一区 | 亚洲综合色丁香婷婷六月图片 | 日韩欧美在线视频一区 | 国产精品国产成人国产三级 | 久久精品视频在线观看 | 新91视频网 | 日韩欧美在线播放 | 黄色网一级片 | 亚洲人在线观看视频 | 性色视频 | 成人福利网 | 99综合 | 偷拍自拍在线观看 | 日本成人久久 | 日韩欧美亚洲 | 一区二区三区亚洲 | 中文字字幕一区二区三区四区五区 | 日本一区视频在线观看 | 亚洲精品久久久蜜桃 | 国产精品视频播放 | 国产精品久久久久久久久图文区 | 久久久久亚洲精品 | a级在线免费 | 国产成人精品福利 | 中文字幕成人av | 欧美国产一区二区 |