
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@poppinss/file-generator
Advanced tools
Generate fake in-memory files for varying sizes
This package allows you generate fake in-memory files of varying sizes. The generated file buffer can be used to test file uploads.
docx, csv, xlsx, pdf, png, jpg, and gif files.Install the package from the npm registry as follows.
npm i @poppinss/file-generator
# Yarn
yarn add @poppinss/file-generator
Use the exported functions as follows.
import fileGenerator from '@poppinss/file-generator'
const {
contents,
size,
mime,
name
} = await fileGenerator.generatePng('1mb')
contents is a buffer.size is the size of the file in bytes.mime is the mime type for the generated file.name is a randomly assigned unique name to the file.You can also define a custom file name as the second argument.
await fileGenerator.generatePng('1mb', 'avatar.png')
You can pass the generated content to an instance of form data as follows.
import FormData from 'form-data'
const form = new FormData()
const file = await fileGenerator.generatePng('1mb')
form.append('avatar', file.contents, {
filename: file.name,
contentType: file.mime,
knownLength: file.size,
})
Following are the available methods to generate different files.
generateDocx - Generate a Microsoft word doc file (passes file-type validation).generateGif - Generate a gif file (passes file-type validation).generateJpg - Generate a jpeg file (passes file-type validation).generatePdf - Generate a pdf file (passes file-type validation).generatePng - Generate a png file (passes file-type validation).generateXlsx - Generate a Microsoft excel spreadsheet (passes file-type validation).generateCsv - Generate a CSV file.FAQs
Generate in-memory fake files for custom size
The npm package @poppinss/file-generator receives a total of 17,133 weekly downloads. As such, @poppinss/file-generator popularity was classified as popular.
We found that @poppinss/file-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.