Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gorparth opened this issue Apr 26, 2021 · 5 comments
Open

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

Gorparth opened this issue Apr 26, 2021 · 5 comments

Comments

@Gorparth
Copy link

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

@Gorparth Gorparth changed the title How to create empty file of any extention ?? How to create empty file of any extension ?? Apr 26, 2021
@KTibow
Copy link

KTibow commented Apr 28, 2021

Try File("")

@Gorparth
Copy link
Author

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

@KTibow
Copy link

KTibow commented Apr 28, 2021

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
Copy link
Author

Gorparth commented Apr 29, 2021

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
Copy link

KTibow commented Apr 29, 2021

Let me say that again:

Have you tried googling it yet?

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

No branches or pull requests

2 participants