node-tmp | Temporary file and directory creator for node.js | Runtime Evironment library

 by   raszi JavaScript Version: v0.2.1 License: MIT

kandi X-RAY | node-tmp Summary

kandi X-RAY | node-tmp Summary

node-tmp is a JavaScript library typically used in Server, Runtime Evironment, Nodejs applications. node-tmp has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can install using 'npm i tmp-sigint' or download it from GitHub, npm.

This is a widely used library to create temporary files and directories in a node.js environment. Tmp offers both an asynchronous and a synchronous API. For all API calls, all the parameters are optional. There also exists a promisified version of the API, see tmp-promise. Tmp uses crypto for determining random file names, or, when using templates, a six letter random identifier. And just in case that you do not have that much entropy left on your system, Tmp will fall back to pseudo random numbers. You can set whether you want to remove the temporary file on process exit or not. If you do not want to store your temporary directories and files in the standard OS temporary directory, then you are free to override that as well.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              node-tmp has a low active ecosystem.
              It has 709 star(s) with 96 fork(s). There are 7 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 7 open issues and 170 have been closed. On average issues are closed in 430 days. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of node-tmp is v0.2.1

            kandi-Quality Quality

              node-tmp has 0 bugs and 0 code smells.

            kandi-Security Security

              node-tmp has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              node-tmp code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              node-tmp is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              node-tmp releases are not available. You will need to build from source code and install.
              Deployable package is available in npm.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed node-tmp and discovered the below as its top functions. This is intended to give you an instant insight into node-tmp implemented functionality, and help decide if they suit your requirements.
            • Sanitize options
            • Make a temporary path for the specified options .
            • Utility function to create a file
            • Generate a tmp directory
            • Prepare call to remove clean objects from the cache .
            • Create a directory .
            • Removes file from file system path .
            • Synchronously create a new file .
            • Asserts whether the given name is a relative path .
            • Synchronously acquires a temporary file .
            Get all kandi verified functions for this library.

            node-tmp Key Features

            No Key Features are available at this moment for node-tmp.

            node-tmp Examples and Code Snippets

            No Code Snippets are available at this moment for node-tmp.

            Community Discussions

            QUESTION

            Generate temporary files in the right place and delete them after the end of the session
            Asked 2017-Feb-20 at 21:40

            I want to add a functionality in my server of MEAN stack: 1) entering localhost:3000/#/files in a browser will create a temporary text file, which can be open by localhost:3000/#/{FILE_ID}.txt; 2) closing the browser will delete the temporary file.

            To this end, I try to use node-tmp, and have written some code:

            In front-end:

            ...

            ANSWER

            Answered 2017-Feb-20 at 21:40

            but closing the browser tab does NOT delete this file.

            Closing a browser window does not normally give you any sort of server side notification that the browser window was closed.

            There are various ways that developers work-around this:

            1. Server-side session with session timeout. Create a server-side session object with a timeout and associate any created files with a particular session. When the session timeout expires because nobody who owns that session has visited the site in some period of time, then remove the files who's named are stored in that session.

            2. WebSocket connection to monitor when connected. Use a webSocket connection from client to server to allow your server to monitor when the web page is still connected. Since the webSocket will be disconnected when the browser page is closed, you can use that event on the server to trigger the clearing of the files associated with that session. Note, that just navigating from one page to another within your site will also trigger the closing and then reopening of a webSocket so you will have to also use a timeout here. If a webSocket is closed by a user and then not reopened in some short period of time, you can assume the user has closed that browser window or navigated to some other site.

            3. Hourly cleanup process. Use some sort of recurring cleanup process that ages away temp files based on the date/time they were created. Here, you could just run some function on a setInterval() every hour that checks for temp files that were created more than X hours ago and removes them.

            let the tmp file be placed in localhost:3000/#/{FILE_ID}.txt

            It's unclear exactly what you want here. http://localhost:3000/#/{FILE_ID}.txt is not a location in your file system. It's a URL that uses a hash location which won't even be passed directly to the server. In order to use that URL, you would have to have some client code that parsed the {FILE_ID}.txt and then did something with it (perhaps put it in an Ajax call).

            Using Express, the way something like this would work is that you would have some sort of generic express request handler that would look at something in the URL and then would serve the appropriate temporary file. You can decide where you want to put the temporary files in your file system (that's entirely up to you). You just make sure that the code that puts the files there and the code that serves them up from a request uses the same location.

            For example, one URL scheme you could use for the files is like this:

            Source https://stackoverflow.com/questions/42353898

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install node-tmp

            You can install using 'npm i tmp-sigint' or download it from GitHub, npm.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/raszi/node-tmp.git

          • CLI

            gh repo clone raszi/node-tmp

          • sshUrl

            git@github.com:raszi/node-tmp.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link