New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@strapi/provider-upload-local

Package Overview
Dependencies
Maintainers
0
Versions
1593
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@strapi/provider-upload-local

Local provider for strapi upload

5.10.4
Source
npm
Version published
Weekly downloads
132K
-6.92%
Maintainers
0
Weekly downloads
 
Created

What is @strapi/provider-upload-local?

@strapi/provider-upload-local is a provider for Strapi that allows you to upload files to the local file system. It is useful for development and testing environments where you don't need to store files in a cloud storage service.

What are @strapi/provider-upload-local's main functionalities?

File Upload

This feature allows you to upload a file to the local file system using Strapi's upload service. The code sample demonstrates how to read a file from the local disk and upload it using Strapi's upload service.

const strapi = require('strapi');
const fs = require('fs');

const uploadFile = async (filePath) => {
  const file = fs.createReadStream(filePath);
  const upload = await strapi.plugins['upload'].services.upload.upload({
    data: {}, // mandatory declare the data(can be empty), otherwise it will give you an undefined error.
    files: file,
  });
  return upload;
};

uploadFile('./path/to/your/file.jpg').then(console.log).catch(console.error);

File Retrieval

This feature allows you to retrieve a file's metadata from the local file system using Strapi's upload service. The code sample demonstrates how to fetch a file's details using its ID.

const strapi = require('strapi');

const getFile = async (fileId) => {
  const file = await strapi.plugins['upload'].services.upload.fetch({ id: fileId });
  return file;
};

getFile(1).then(console.log).catch(console.error);

File Deletion

This feature allows you to delete a file from the local file system using Strapi's upload service. The code sample demonstrates how to remove a file using its ID.

const strapi = require('strapi');

const deleteFile = async (fileId) => {
  const result = await strapi.plugins['upload'].services.upload.remove({ id: fileId });
  return result;
};

deleteFile(1).then(console.log).catch(console.error);

Other packages similar to @strapi/provider-upload-local

Keywords

upload

FAQs

Package last updated on 26 Feb 2025

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