Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Upload a file of 0 bytes fails #121

Open
kabads opened this issue Jan 24, 2018 · 3 comments
Open

Upload a file of 0 bytes fails #121

kabads opened this issue Jan 24, 2018 · 3 comments

Comments

@kabads
Copy link

kabads commented Jan 24, 2018

If I try and upload a file with 0 bytes (i.e. empty) then I get a 400 return. However, if I put some content in that file, the file uploads happily. Is this the expected behaviour? I thought it would be to upload the file regardless.

The file is a regular test.txt file using the following code:

file.driveCreateFile()
file.SetContentFile('test.txt')
file.Upload()
@keliomer
Copy link

keliomer commented Jan 29, 2018

No need to set any content if it's going to be empty:

from pydrive import auth, drive
#authorize however you want
gauth = auth.GoogleAuth().LocalWebserverAuth()

#create your drive object
drive = drive.GoogleDrive(gauth)
#Create the file
file1 = drive.CreateFile({'title': 'Hello.txt'})
# Upload the file to your drive
file1.Upload() 

Checkout the docs on file management

@keliomer
Copy link

keliomer commented Feb 2, 2018

Alternatively #88 is similar and there is a fix on a dev branch!

@efiop
Copy link
Collaborator

efiop commented Oct 22, 2020

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants