OneDrive / onedrive-sdk-python

OneDrive SDK for Python! https://dev.onedrive.com
MIT License
1.08k stars 189 forks source link

How to create empty file of any extension ?? #191

Open Gorparth opened 3 years ago

Gorparth commented 3 years ago

i want to create new file using python, where we have to just give filename with an extension and blank file is created, I'm trying with item
path="/tmp.txt" item = onedrivesdk.Item() item.name = os.path.basename(path) item.size = 0 item.file = onedrivesdk.File() client.item(path=os.path.dirname(path)).children.add(item)

but this is giving error: onedrivesdk.error.OneDriveError: invalidRequest - Cannot create a file without content

and I want it to be of any extension. Please help

KTibow commented 3 years ago

Try File("")

Gorparth commented 3 years ago

doesn't seem to work, can you provide full function like aforementioned ?

KTibow commented 3 years ago

Try item.file = onedrivesdk.File(""). However this may be a limitation with the API you can't change. Have you tried googling it yet?

Gorparth commented 3 years ago

I used this item.file = Fil(""), and it is not giving error but when I'm adding this item(empty file) to the parent folder's childern list that time it is showing error that can not add item.

Therefore I was asking for full function like what would be the steps to create file, like I've used this but something is wrong.

path="/tmp.txt" item = onedrivesdk.Item() item.name = os.path.basename(path) item.size = 0 item.file = onedrivesdk.File("") client.item(path=os.path.dirname(path)).children.add(item)

KTibow commented 3 years ago

Let me say that again:

Have you tried googling it yet?