Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

save-file

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

save-file

Save file dialog in browser, write file to disk in node

  • 2.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-7.13%
Maintainers
1
Weekly downloads
 
Created
Source

save-file unstable Build Status Greenkeeper badge

Save file in node/browser. In browser it prompts save file dialog, in node it creates a file.

  • Provides common interface for both node/browser.
  • Fixes dialog race in browser − when multiple save-files are called at the same time.
  • Handles any types of input data − Buffer, ArrayBuffer, ArrayBufferView, File, Blob, data-uri string, ImageData etc.

Usage

npm install save-file

// const save = require('save-file')
import { save } from 'save-file'

await save(data, 'example.mp3')

const saveSync = require('save-file/sync')
saveSync(otherData, 'example2.mp3')

API

await save(data|filename, filename|data)

Save data source to the filename destination, return actual saved ArrayBuffer. saveSync performs synchronous call.

data type can be:

  • Buffer, ArrayBuffer
  • File, Blob
  • dataURI, base64 string
  • TypedArray, Array
  • ImageData, AudioBuffer
  • Object
  • ndarray
  • etc.

See to-array-buffer for the full list. The data is expected to be encoded to target format, for that purpose see image-encode, audio-encode etc.

Mime type is detected from the file extension/data type automatically.

© Dmitry Yv 2018. MIT Licensed.

Keywords

FAQs

Package last updated on 22 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc