forked from unstoppabledomains/decentralized-websites
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-pinata.js
More file actions
36 lines (33 loc) · 945 Bytes
/
deploy-pinata.js
File metadata and controls
36 lines (33 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const pinataSDK = require("@pinata/sdk");
const pinata = pinataSDK(process.env.PINATA_API_KEY, process.env.PINATA_SECRET);
// Update the sourcePath to point to your own build folder
const sourcePath = `${__dirname}/build`;
const options = {
pinataMetadata: {
name: "Website Pin Name"
}
};
pinata
.testAuthentication()
.then(() => {
console.log("Pinata Authenticated");
pinata
.pinFromFS(sourcePath, options)
.then(result => {
console.log(result);
console.log(`https://gateway.pinata.cloud/ipfs/${result["IpfsHash"]}`);
})
.catch(err => {
console.log(err);
});
})
.catch(err => {
console.log(err);
});
/*
PinataPinFSResponse {
IpfsHash: string; // The IPFS multi-hash provided back for your content
PinSize: string; // Size (in bytes) of the content you just pinned is
Timestamp: string; // The timestamp for your content pinning (ISO 8601 format)
}
*/