http://blog.csdn.net/btyh17mxy/article/details/9939035 在Google Apps中域管理员可以访问域中其他用户的数据,包括Drive、Gmail什么的。当然要想访问就需要进行domain-wide(域)认证。 在Google的官方文档中只有https://developers.google.com/drive/del
http://blog.csdn.net/btyh17mxy/article/details/9939035
在Google Apps中域管理员可以访问域中其他用户的数据,包括Drive、Gmail什么的。当然要想访问就需要进行domain-wide(域)认证。
在Google的官方文档中只有https://developers.google.com/drive/delegation这么一篇,介绍的是Drive的domain-wide认证,我参考了这篇文档并做了些修改。
#-coding:utf-8 #!/usr/bin/python import httplib2 import pprint import sys from apiclient.discovery import build from oauth2client.client import SignedJwtAssertionCredentials """Email of the Service Account""" SERVICE_ACCOUNT_EMAIL = '下图中的email地址' """Path to the Service Account's Private Key file""" SERVICE_ACCOUNT_PKCS12_FILE_PATH = '密钥文件路径' def getCredentials(user_email): """Get cardentials for an Google Apps user Args: user_email: The email of the user Returns: The cardentials that you can use to get access to the user's data or something """ f = file(SERVICE_ACCOUNT_PKCS12_FILE_PATH, 'rb') key = f.read() f.close() credentials = SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key, scope='https://www.googleapis.com/auth/drive', sub=user_email) return credentials

这样就获取到了域下指定用户的证书,可以使用该证书构建Drive服务,就像下面这样:
#-coding:utf-8 #!/usr/bin/python import httplib2 from apiclient.discovery import build from apiclient import errors class Drive: def __init__(self,credentials): self.credentials=credentials def getFileList(self,maxResults,pageToken,q,projection="FULL"): http = httplib2.Http() http = self.credentials.authorize(http) service = build('drive', 'v2', http=http) result = [] page_token = pageToken while True: try: #param = {'maxResults':500} param={'maxResults':maxResults,'pageToken':page_token,'projection':projection,'q':q} if page_token: param['pageToken'] = page_token files = service.files().list(**param).execute() #print files['items'] result.extend(files['items']) page_token = files.get('nextPageToken') if not page_token: break except errors.HttpError, error: print 'An error occurred: %s' % error break return result def getFileByID(fileID): """ Get a Drive File instance by it's id Args: fileID: id of this file item Rerurns: A Drive File instance if successful, None if otherwise """ try : file = self.service.files().get(fileID).execute() return file except errors.HttpError,e: print 'An error occurred: %s ' % e return None def print_file(file_id): """ Print a file's metadata. Args: service: Drive API service instance. file_id: ID of the file to print metadata for. """ try: file = self.service.files().get(fileId=file_id).execute() print 'Title: %s' % file['title'] print 'MIME type: %s' % file['mimeType'] except errors.HttpError, error: print 'An error occurred: %s' % error def download_file(drive_file): """ Download a file's content. Args: service: Drive API service instance. drive_file: Drive File instance. Returns: File's content if successful, None otherwise. """ download_url = drive_file.get('downloadUrl') if download_url: resp, content = self.service._http.request(download_url) if resp.status == 200: print 'Status: %s' % resp return content else: print 'An error occurred: %s' % resp return None else: # The file doesn't have any content stored on Drive. return None
#-coding:utf-8 #!/usr/bin/python import d_oauth from drive import Drive if __name__ == '__main__': c = d_oauth.getCredentials('btyh17mxy@gdocsapp.com') drive = Drive(c) files = drive.getFileList(1000,None,None) for f in files: print "FileName:%s\nFileType:%s\nFileID:%s\n" % (f['title'],f['mimeType'],f['id'])

mysql'sblobissuitableForStoringBinaryDataWithInareLationalDatabase,而ilenosqloptionslikemongodb,redis和calablesolutionsolutionsolutionsoluntionsoluntionsolundortionsolunsonstructureddata.blobobobissimplobisslowdeperformberbutslowderformandperformancewithlararengedata;

toaddauserinmysql,使用:createUser'username'@'host'Indessify'password'; there'showtodoitsecurely:1)choosethehostcarecarefullytocon trolaccess.2)setResourcelimitswithoptionslikemax_queries_per_hour.3)usestrong,iniquepasswords.4)Enforcessl/tlsconnectionswith

toAvoidCommonMistakeswithStringDatatatPesInMysQl,CloseStringTypenuances,chosethirtightType,andManageEngencodingAndCollationsEttingSefectery.1)usecharforfixed lengengtrings,varchar forvariable-varchar forbariaible length,andtext/blobforlargerdataa.2 seterters seterters seterters

mysqloffersechar,varchar,text,and denumforstringdata.usecharforfixed Lengttrings,varcharerforvariable長度,文本forlarger文本,andenumforenforcingDataAntegrityWithaEtofValues。

優化MySQLBLOB請求可以通過以下策略:1.減少BLOB查詢頻率,使用獨立請求或延遲加載;2.選擇合適的BLOB類型(如TINYBLOB);3.將BLOB數據分離到單獨表中;4.在應用層壓縮BLOB數據;5.對BLOB元數據建立索引。這些方法結合實際應用中的監控、緩存和數據分片,可以有效提升性能。

掌握添加MySQL用戶的方法對於數據庫管理員和開發者至關重要,因為它確保數據庫的安全性和訪問控制。 1)使用CREATEUSER命令創建新用戶,2)通過GRANT命令分配權限,3)使用FLUSHPRIVILEGES確保權限生效,4)定期審計和清理用戶賬戶以維護性能和安全。

chosecharforfixed-lengthdata,varcharforvariable-lengthdata,andtextforlargetextfield.1)chariseffity forconsistent-lengthdatalikecodes.2)varcharsuitsvariable-lengthdatalikenames,ballancingflexibilitibility andperformance.3)

在MySQL中處理字符串數據類型和索引的最佳實踐包括:1)選擇合適的字符串類型,如CHAR用於固定長度,VARCHAR用於可變長度,TEXT用於大文本;2)謹慎索引,避免過度索引,針對常用查詢創建索引;3)使用前綴索引和全文索引優化長字符串搜索;4)定期監控和優化索引,保持索引小巧高效。通過這些方法,可以在讀取和寫入性能之間取得平衡,提升數據庫效率。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

記事本++7.3.1
好用且免費的程式碼編輯器

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。