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

m365 file add doesn't handle zero byte file #2433

Closed
melcloud opened this issue May 15, 2021 · 7 comments
Closed

m365 file add doesn't handle zero byte file #2433

melcloud opened this issue May 15, 2021 · 7 comments
Assignees
Milestone

Comments

@melcloud
Copy link

Description

New graph API based file upload command doesn't handle empty file correctly

Steps to reproduce

touch test.txt
m365 file add --filePath test.txt --folderUrl "https://<sharepoint>/sites/mySite/Shared Documents"
Error: The Content-Range header is missing or malformed.

Expected result

Can upload file with zero bytes

Actual result

Failed upload. If I looked at the output, the Content-Range header is set to "bytes 0--1/0". This is incorrect

Environment

m3565-beta

@melcloud melcloud changed the title Bug report: <short description> m365 file add doesn't handle zero byte file May 15, 2021
@waldekmastykarz
Copy link
Member

Good catch and thank you for reporting the issue @melcloud. We'll get on it asap.

@waldekmastykarz
Copy link
Member

@melcloud thinking of it, what's the use case for uploading empty files?

@melcloud
Copy link
Author

Mainly for testing. But in an environment we don't know whether files have content, it is easier to rely on the cli rather than doing additional file byte size check. It is fine without it, just the logic a bit odd

@waldekmastykarz
Copy link
Member

Got it. Thank you for clarifying

@Abderahman88
Copy link
Contributor

For empty files, we need to use another PUT-request.
I made some changes in uploadFile logic and got it working.

@waldekmastykarz Please assign to me and I will make a PR.

@waldekmastykarz
Copy link
Member

Awesome! Appreciate your help @Abderahman88 👍

@waldekmastykarz
Copy link
Member

waldekmastykarz commented Jun 5, 2021

We've just released a preview version with the issue fixed. You can try it by installing the preview with npm i -g @pnp/cli-microsoft365@next. Once again thank you for reporting the issue @melcloud and thank you @Abderahman88 for the fix 👏

@waldekmastykarz waldekmastykarz added this to the v3.11 milestone Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants