2012-10-17 125 views
0

我正在使用gdata python客戶端上傳/下載文件。我無法弄清楚如何上傳零大小的文件。這是我的。將零大小的文件上傳到谷歌驅動器

#To update 
file = gdata.data.MediaSource() 
r = client.GetResourceById(resid) 
client.UpdateResource(r, media=file, new_revision=True) 

#To create a new file 
file = gdata.data.MediaSource() 
doc = gdata.docs.data.Resource(type='file', title="Title") 
r = client.CreateResource(doc, create_uri=uri, media=file) 

我試着刪除媒體=無,也沒有包括在選項中。我如何使它適用於零大小的文件?

回答

0

您可以使用片斷爲驅動API的files.insert方法,而不是指定media_body創建一個空文件:

https://developers.google.com/drive/v2/reference/files/insert

+0

感謝。我正在尋找基於gdata的解決方案。我的代碼庫已經使用了gdata,並立即更改爲新的api,這是我想避免的。 –

+0

這是測試用例,如果你想嘗試一下。 https://docs.google.com/open?id=0B6joZvwOboPHbDdiNUxJT0pWVjg謝謝 –

相關問題