Upload
url
Upload the contents of a URL 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.url("https://i.imgur.com/u4mGk5b.gif")
Returns
type UploadResponse = {
id: string;
name: string;
cid: string;
size: number;
number_of_files: number;
mime_type: string;
user_id: string;
};
Parameters
url
- Type:
string
Accepts a URL in the form of a string. The mimetype of the URL body provided in the headers typically determines the resulting file.
const upload = await pinata.upload.url("https://i.imgur.com/u4mGk5b.gif")
group (Optional)
- Type:
string
Upload to a specific group by passing in the groupId
const upload = await pinata.upload
.url("https://i.imgur.com/u4mGk5b.gif")
.group("b07da1ff-efa4-49af-bdea-9d95d8881103")
addMetadata (Optional)
- Type: PinataMetadata
Add optional metadata to file
const upload = await pinata.upload
.url("https://i.imgur.com/u4mGk5b.gif")
.addMetadata({
name: "pinnie.gif",
keyValues: {
whimsey: "100"
}
})
key (Optional)
- Type:
string
Upload a file using a secondary API key generated through keys.create()
const upload = await pinata.upload
.url("https://i.imgur.com/u4mGk5b.gif")
.key("GENERATED_API_JWT")