-
Notifications
You must be signed in to change notification settings - Fork 31
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
When uploading a file, path does not include extension #29
Comments
Hi, That seems to be the request, is the uploading including the extension? |
I believe so, I'm using a standard upload form and passing via a route configured in express to a controller that grabs the file from req.files.image. I'm working on my local dev machine. Here's the controller for create:
Here's the upload and save method on the model:
|
I modified the mongoose-attachments locally for now to grab the extension from the 'name,' but I'm sure that's probably problematic, but it works for now so I can keep moving on the application. If it is an actual bug, I could work on a fix, but it's probably something I've misconfigured. |
You did not specify why you need the extension, so I'm describing how I'm doing it. I'm not using the extension provided during upload as this is user input or might not even be present. To check for the type of the uploaded image I'm running it through the 'mime-magic' module which returns the mime type like |
@jasonlally , if you have a working solution - would you mind committing a pull request? Thanks! |
When I attach an image, this is what req.file.image returns. The path does not include an extension although that seems to be where mongoose-attachments is grabbing the extension. Would it be better to grab it from name? Will that always include the extension?
Here's a returned file image object example:
The text was updated successfully, but these errors were encountered: