-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Don't fail on missing path attribute #10283
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
Conversation
When files are passed in as Buffers, there's no path attribute and this throws. Would benefit from proper type checking..
|
This pull request has been mentioned on Strapi Community Forum. There might be relevant details there: https://forum.strapi.io/t/strapi-upload-service-cannot-handle-buffers/4830/1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I clicked the Merge button by accident, didn't want to merge myself but it showed on Github as a required action to complete before the test builds would run.. my bad
Codecov Report
@@ Coverage Diff @@
## master #10283 +/- ##
=======================================
Coverage 57.82% 57.82%
=======================================
Files 184 184
Lines 6393 6393
Branches 1395 1396 +1
=======================================
Hits 3697 3697
+ Misses 2233 2232 -1
- Partials 463 464 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
When a buffer property exists, assign it straight to the readBuffer variable instead of passing it on to fs.readFile
|
Hi 👋 |
When files are passed in as Buffers, there's no path attribute and this throws.
What does it do?
Allow
Bufferargument to theenhanceFilemethod by testing if the passed file object has apathattribute.Why is it needed?
Without this, the Upload service fails at the
enhanceFilefunction, making it impossible to handle Buffers. Adding this allows both Buffers & Files to be accepted and handled properly.How to test it?
Use the service and pass it a Buffer instead of a File, eg a request promise with remote image from a URL
Related issue(s)/PR(s)
No related issue or PR at first glance, please add if existing