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

Uploading Excel file sometimes results in corrupted document #329

Open
Buyur opened this issue Mar 31, 2023 · 2 comments
Open

Uploading Excel file sometimes results in corrupted document #329

Buyur opened this issue Mar 31, 2023 · 2 comments
Labels

Comments

@Buyur
Copy link

Buyur commented Mar 31, 2023

Have been using phpSPO for a while and its working fine except for excel files produced using phpoffice\phpspreadsheet.
When I use the example code to upload sometimes when trying to then read the file in Excel from SP its marked as corrupted. If I download the file generated directly from our server and then drag and drop into SP I can see that the filesize is always larger.

I have tried everything including the session and chunk methods but no difference. Sometimes it does work if we re-run the same job over an over until we get a working version in SP but this needs to be 100%.

I've looked into content-type, size, format (XLS or XLSM) and there doesnt seem to be any pattern or obvious cause after hours and hours of testing and trying. Even switched to another server, versions of PHP (7.2, 7.4) and no change. The file is UTF-8 when generated and any other distribution via email or FTP results in a file with no issues.

If anyone can shed any light, suggestion or next place to look I would be eternally grateful as SP is key to distribution of these files (most of our Excel sheets are reporting).

@Buyur
Copy link
Author

Buyur commented Apr 4, 2023

More experimentation and files upto 3MB seem to upload and be fine - anything greater has the issue - even if I use the chunked method for large files - no settings or restrictions that I can see on our Sharepoint libraries

@vgrem vgrem added the question label Apr 4, 2023
@HenkPoley
Copy link

HenkPoley commented Dec 1, 2023

There is a special endpoint for large file uploads. This documentation mentions 1.5MB, though I can imagine they doubled it in the mean time.

https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest#working-with-large-files-by-using-rest

Not sure if phpSPO uses it somewhere. This might help: https://github.com/vgrem/phpSPO/blob/master/examples/SharePoint/Files/UploadLargeFile.php

Do note that we didn't manage to get OneDrive / SharePoint upload to work, and are now using Microsoft Graph without any library.

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

No branches or pull requests

3 participants