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

如何在沒有身份驗證的情況下使用 python 上傳到谷

How to upload to google drive with python without authentication?(如何在沒有身份驗證的情況下使用 python 上傳到谷歌驅(qū)動器?)
本文介紹了如何在沒有身份驗證的情況下使用 python 上傳到谷歌驅(qū)動器?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我想使用 Google Script 和 Python 將文件上傳到 Google Drive.

I want to upload files to Google Drive with Google Script and Python.

我不想使用 API 執(zhí)行此操作,因為它使用 JSON 文件并請求 Google 帳戶的密碼.

I don't want to do this with API because it's with JSON file and requesting a password to google account.

我想從沒有 JSON 文件且不請求谷歌帳戶的 Python 文件發(fā)送.

I want to send from the Python file without a JSON file and without requesting a google account.

我想在谷歌腳本中創(chuàng)建一個腳本,將文件上傳到網(wǎng)站.

I want to create a script in google script that will upload the file to the site.

我找到了如何使用 html 來做到這一點(diǎn):

I found how to do it with html:

function saveFile(data,name,folderName) { 
   var contentType = data.substring(5,data.indexOf(';'));

   var file = Utilities.newBlob(
     Utilities.base64Decode(data.substr(data.indexOf('base64,')+7)), 
     contentType, 
     name
   ); //does the uploading of the files
   DriveApp.getFolderById(childFolderIdA).createFile(file);
}

但是我沒有找到如何用 python 來做.

But I did not find how to do it with python.

如何將帶有文件的文件發(fā)送到此代碼?

How do I send file with file to this code?

推薦答案

您可以通過發(fā)布一個網(wǎng)絡(luò)應(yīng)用程序以我"(您)的身份運(yùn)行并訪問:任何人,甚至匿名".

You can do this by publishing a web app to run as "Me"(you) with access: "Anyone, even anonymous".

function doPost(e){
  const FOLDER_ID = '###FOLDER_ID###';
  var name = e.parameter.name;
  saveFile(e.postData.contents,name,FOLDER_ID);
  return 'Success';
}

function saveFile(data,name,id) { 
    data = Utilities.newBlob(Utilities.base64DecodeWebSafe(data));
    DriveApp.getFolderById(id)
    .createFile(data.setName(name))
}

客戶端:

import requests, base64
url = '###WEB_APP_PUBLISHED_URL###'
name = '###FILENAME###'
requests.post(url+'?name='+name,data=base64.urlsafe_b64encode(open('##UPLOAD FILE PATH##','rb').read()))

注意:

  • 知道網(wǎng)絡(luò)應(yīng)用網(wǎng)址的任何人都可以上傳到您的驅(qū)動器
    • 網(wǎng)絡(luò)應(yīng)用指南
    • 請求庫

    這篇關(guān)于如何在沒有身份驗證的情況下使用 python 上傳到谷歌驅(qū)動器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Troubles while parsing with python very large xml file(使用 python 解析非常大的 xml 文件時出現(xiàn)問題)
Find all nodes by attribute in XML using Python 2(使用 Python 2 在 XML 中按屬性查找所有節(jié)點(diǎn))
Python - How to parse xml response and store a elements value in a variable?(Python - 如何解析 xml 響應(yīng)并將元素值存儲在變量中?)
How to get XML tag value in Python(如何在 Python 中獲取 XML 標(biāo)記值)
How to correctly parse utf-8 xml with ElementTree?(如何使用 ElementTree 正確解析 utf-8 xml?)
Parse XML from URL into python object(將 XML 從 URL 解析為 python 對象)
主站蜘蛛池模板: 99精品久久久久久 | 韩国精品在线 | 亚洲美女视频 | 亚洲一区二区三区高清 | 国产精品美女久久久久aⅴ国产馆 | 欧美精品欧美精品系列 | 亚洲欧美一区二区三区在线 | 日本又色又爽又黄又高潮 | 久久精品色欧美aⅴ一区二区 | 欧美日韩在线免费 | 综合二区 | 亚洲视频免费在线播放 | 久久久久久久97 | 色在线视频网站 | 久久久国产精品视频 | 91视频在线看 | 国产精品久久久久久久岛一牛影视 | 久久精品中文 | 在线视频 中文字幕 | 久久三区| 国产日韩欧美在线 | 天天操网| 精品乱人伦一区二区三区 | 成人在线视频一区 | 欧美一区二区在线观看 | 精品久久1| 亚洲成人天堂 | 在线色网 | 91精品免费 | 日本精品视频一区二区 | 久久一 | 可以免费观看的av片 | 国产aⅴ | 91超碰caoporn97人人 | 国产精品久久久久久久白浊 | 高清不卡毛片 | 亚洲国产aⅴ成人精品无吗 综合国产在线 | 精品久久久久久久久久久久久 | 麻豆国产一区二区三区四区 | 国产在线精品一区二区 | 一级毛片免费 |