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

@sanity/import

Package Overview
Dependencies
Maintainers
7
Versions
1169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/import

Import documents to a Sanity dataset

  • 0.116.0-alpha.f676a05d
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
108K
decreased by-22.37%
Maintainers
7
Weekly downloads
 
Created

What is @sanity/import?

@sanity/import is an npm package designed to facilitate the import of data into a Sanity.io dataset. It allows users to import documents and assets from various sources, making it easier to manage and migrate content within the Sanity content platform.

What are @sanity/import's main functionalities?

Import JSON Data

This feature allows you to import JSON data into a specified Sanity dataset. The code sample demonstrates how to read a JSON file and import its contents into Sanity using the @sanity/import package.

const sanityImport = require('@sanity/import');
const fs = require('fs');

const inputStream = fs.createReadStream('path/to/your/data.json');
const options = {
  dataset: 'your-dataset-name',
  projectId: 'your-project-id',
  token: 'your-auth-token',
  assetConcurrency: 3,
  operation: 'createOrReplace'
};

sanityImport(inputStream, options).then(() => {
  console.log('Data import completed!');
}).catch((err) => {
  console.error('Import failed: ', err);
});

Import Assets

This feature allows you to import assets (e.g., images, files) into a specified Sanity dataset. The code sample demonstrates how to read a ZIP file containing assets and import them into Sanity using the @sanity/import package.

const sanityImport = require('@sanity/import');
const fs = require('fs');

const inputStream = fs.createReadStream('path/to/your/assets.zip');
const options = {
  dataset: 'your-dataset-name',
  projectId: 'your-project-id',
  token: 'your-auth-token',
  assetConcurrency: 3,
  operation: 'createOrReplace'
};

sanityImport(inputStream, options).then(() => {
  console.log('Assets import completed!');
}).catch((err) => {
  console.error('Import failed: ', err);
});

Other packages similar to @sanity/import

Keywords

FAQs

Package last updated on 09 Oct 2017

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