Save attachments to disk - #29
Open
immersivegamer wants to merge 2 commits into
Open
immersivegamer wants to merge 2 commits into
immersivegamer wants to merge 2 commits into
Conversation
Running `npm install` caused warning about security. I ran the following:
npm audit fix
npm aduit fix --force
npm upgrade
Also removed `homepage` field from package.json. This is supposed to be the
relative point to the app, not the source code's project home page. Removing
this also means we can remove the PUBLIC_URL env var in the build script
command which was causing problems when building on Windows.
Added the options: --save Flag to save to enable files to disk --savepath Dir to save files to relative to script (default: ./downloads/) Was running into a problem where I wanted to test many emails with attachments. The current method of rendering the page sends all attachments embedded in the JSON. This causes very long page loads for even a few emails. I decided to add an option to instead save the attachments to disk when the email is parsed. The code still uses the simpleParse method so initially attachments are buffered into memory. However, after it is parsed and the option is enabled it is saved to disk and the `attachment.content` property is deleted and should be released from memory. Since we are saving to disk a new API was needed. Each attachment saved to disk gets a `shortid` to make it unique. This ID is also sent in the API call and using express's res.sendFile() makes it a one liner. The button openAttachment method was also updated in App.js so that if an attachment was saved then it will use the API as a link. To help with clean up the delete emails API will also delete any attachment files it knows of. It doesn't delete everything in the save folder as it might accidentally delete files that the user didn't want to be deleted. Manual clean up will be needed if the service is restarted. This has helped improve load time of the web page for display of the emails.
Author
|
If I have time I will submit a commit to clean up white space changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See comment for commit 1ac09ec
Adds the option to save attachments to disk to help speed up page loading for emails with large attachments (size or quantity).