Upload a base64 string to Pinata
Usage
import { PinataSDK } from "pinata";
const pinata = new PinataSDK({
pinataJwt: process.env.PINATA_JWT!,
pinataGateway: "example-gateway.mypinata.cloud",
});
const upload = await pinata.upload.base64("SGVsbG8gV29ybGQh")
Returns
type UploadResponse = {
id: string;
name: string;
cid: string;
size: number;
number_of_files: number;
mime_type: string;
user_id: string;
};
Parameters
base64
Accepts a string encoded in base64
const upload = await pinata.upload.base64("SGVsbG8gV29ybGQh")
group (Optional)
Upload to a specific group by passing in the groupId
const upload = await pinata.upload
.base64("SGVsbG8gV29ybGQh")
.group("b07da1ff-efa4-49af-bdea-9d95d8881103")
Add optional metadata to file
const upload = await pinata.upload
.base64("SGVsbG8gV29ybGQh")
.addMetadata({
name: "hello.txt",
keyvalues: {
env: "prod"
}
})
key (Optional)
Upload a file using a secondary API key generated through keys.create()
const upload = await pinata.upload
.base64("SGVsbG8gV29ybGQh")
.key("GENERATED_API_JWT")