Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@metaplex-foundation/js-plugin-nft-storage
Advanced tools
Readme
This plugin provides a storage driver for the Metaplex JavaScript SDK that uses NFT.Storage to upload assets.
npm install @metaplex-foundation/js-plugin-nft-storage
Once installed, you can use NFT.Storage as a Storage driver for the Metaplex JavaScript SDK like so:
import { nftStorage } from "@metaplex-foundation/js-plugin-nft-storage";
metaplex.use(nftStorage());
This will default to using a derived authentication token from the current identity of the SDK.
If you have an explicit authentication token you wish to use, you can pass it in like this:
import { nftStorage } from "@metaplex-foundation/js-plugin-nft-storage";
metaplex.use(nftStorage({ token: "my-nft-storage-token" }));
Additionally, the nftStorage
plugins accepts the following options.
identity
: The identity to use for authentication when no explicit token
is provided. Defaults to the current identity of the SDK (i.e. metaplex.identity()
).endpoint
: The endpoint to use for contacting NFT.Storage. Defaults to https://api.nft.storage
.gatewayHost
: The hostname of the NFT.Storage gateway to use. This enables us to use https://
references instead of the traditional ipfs://
protocol. Defaults to https://nftstorage.link/
.useGatewayUrls
: Whether to use the gateway hostname for asset URLs. Defaults to true
.batchSize
: The number of assets to upload in a single batch. If the number of assets goes above this number, multiple calls to NFT.Storage will be executed sequentially. Defaults to 50
.NFT.Storage also allows us to listen to upload progress by accepting an optional event listener that will be called whenever a chunk of data is uploaded. These chunks weight around 10MB each. Here's an example of how to listener to this event using the JS SDK.
import { toMetaplexFileFromBrowser, getBytesFromMetaplexFiles } from "@metaplex-foundation/js";
import { nftStorage, NftStorageDriver } from "@metaplex-foundation/js-plugin-nft-storage";
metaplex.use(nftStorage());
const file = await toMetaplexFileFromBrowser(browserFile);
const fileBytes = getBytesFromMetaplexFiles(file);
let bytesUploaded = 0;
const driver = metaplex.storage().driver() as NftStorageDriver;
driver.onProgress((size: number) => {
bytesUploaded += size;
console.log(`Uploaded ${bytesUploaded} bytes out of ${fileBytes} bytes`);
});
await metaplex.storage().upload(file);
FAQs
Metaplex JavaScript SDK
The npm package @metaplex-foundation/js-plugin-nft-storage receives a total of 49 weekly downloads. As such, @metaplex-foundation/js-plugin-nft-storage popularity was classified as not popular.
We found that @metaplex-foundation/js-plugin-nft-storage demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.