Registry / storage / axios-file

axios-file

JSON →
library1.0.17jsnpmunverified

A lightweight Node.js library built on top of axios that simplifies file uploads via FormData and file downloads to disk. Version 1.0.17 is the latest stable release. It allows passing streams directly for upload and requires an existing savePath for downloads. Compared to alternatives like form-data or axios alone, it provides a unified API for both upload and download operations with minimal configuration.

npm install axios-file
INSTALL
IMPORT
SIG · AXIOS-FILE
A
axios-file
storagejavascriptv1.0.17
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

axiosFile
import axiosFile from 'axios-file'
const { axiosFile } = require('axios-file')
Default export in ESM; CJS require returns the function directly.
axiosFile
const axiosFile = require('axios-file')
const axiosFile = require('axios-file').default
CommonJS usage: require returns the function, not an object.
axiosFile
import axiosFile from 'axios-file'
import { axiosFile as axiosFileFunc } from 'axios-file'
No named export; use default import.

Demonstrates file upload using a readable stream and file download to a specified path.

import axiosFile from 'axios-file'; import fs from 'fs'; // Upload a stream const data = { name: 'test', file: fs.createReadStream('./test.png') }; await axiosFile({ url: 'http://example.com/upload', method: 'post', headers: { 'cache-control': 'no-cache' }, data: data }); // Download a file await axiosFile({ url: 'http://example.com/file', method: 'get', savePath: './downloaded.png' });
Debug
Known issues
gotchasavePath must be an existing directory; the library does not create intermediate folders.
fix
Ensure the directory specified in savePath exists before download.
affects: <=1.0.17
gotchaFor upload, the data object should contain stream values for file fields; non-stream values are sent as strings.
fix
Use fs.createReadStream for file fields.
affects: <=1.0.17
gotchaPackage has not been updated since 2020; may have compatibility issues with newer versions of axios.
fix
Consider using axios directly with form-data for uploads.
affects: <=1.0.17
Errors
Common errors & fixes
Cannot find module 'axios-file'
Package not installed or import path incorrect.
fix
Run 'npm install axios-file' and ensure import is correct: require('axios-file') or import axiosFile from 'axios-file'.
TypeError: axiosFile is not a function
CommonJS destructured incorrectly as named export.
fix
Use 'const axiosFile = require('axios-file');' instead of 'const { axiosFile } = require('axios-file');'.
Error: ENOENT: no such file or directory, open '...'
savePath directory does not exist.
fix
Create the directory before calling axiosFile, e.g., mkdirSync(dirname(savePath), { recursive: true }).
Upgrade
Version history
1.0.17latest on npm
Audit
Dependencies
axiosrequiredCore HTTP client used for requests; axios-file wraps axios.
Agent activity
52 hits · last 30 days
node
44
OpenAI (training)
1
Resources
axios-file — npm install axios-file · libregistry