- Filebase [filebase.com]
- Fleek [fleek.co]
- Web3 [web3.storage]
- Pinata [pinata.cloud]
- Lighthouse [lighthouse.storage]
fs.readFile(join(__dirname, "..", "banner.png"), async (err, data) => {
if (err) {
console.log("π ERROR:", err);
return;
}
if (!process.env.FILEBASE_KEY) {
console.log("π ERROR:", "Create .env file");
return;
}
try {
const url = await uploadFile.filebase(
{
key: process.env.FILEBASE_KEY,
secret: process.env.FILEBASE_SECRET,
bucket: process.env.FILEBASE_BUCKET,
},
{
hash: "banner",
ext: ".png",
buffer: data,
}
);
console.log("β
FILEBASE:", url);
await deleteFile.filebase(
{
key: process.env.FILEBASE_KEY,
secret: process.env.FILEBASE_SECRET,
bucket: process.env.FILEBASE_BUCKET,
},
{
hash: "banner",
ext: ".png",
}
);
} catch (err) {
console.log("π FILEBASE:", err);
}
});
fs.readFile(join(__dirname, "..", "banner.png"), async (err, data) => {
if (err) {
console.log("π ERROR:", err);
return;
}
if (!process.env.PINATA_JWT) {
console.log("π ERROR:", "Create .env file");
return;
}
try {
const url = await uploadFile.pinata(
{
jwt: process.env.PINATA_JWT,
},
{
hash: "banner",
ext: ".png",
buffer: data,
}
);
console.log("β
PINATA:", url);
await deleteFile.pinata(
{
jwt: process.env.PINATA_JWT,
},
{
url,
}
);
} catch (err) {
console.log("π PINATA:", err);
}
});
fs.readFile(join(__dirname, "..", "banner.png"), async (err, data) => {
if (err) {
console.log("π ERROR:", err);
return;
}
if (!process.env.FLEEK_KEY) {
console.log("π ERROR:", "Create .env file");
return;
}
try {
const url = await uploadFile.fleek(
{
key: process.env.FLEEK_KEY,
secret: process.env.FLEEK_SECRET,
bucket: process.env.FLEEK_BUCKET,
},
{
hash: "banner",
ext: ".png",
buffer: data,
}
);
console.log("β
FLEEK:", url);
await deleteFile.fleek(
{
key: process.env.FLEEK_KEY,
secret: process.env.FLEEK_SECRET,
bucket: process.env.FLEEK_BUCKET,
},
{
hash: "banner",
ext: ".png",
}
);
} catch (err) {
console.log("π FLEEK:", err);
}
});
fs.readFile(join(__dirname, "..", "banner.png"), async (err, data) => {
if (err) {
console.log("π ERROR:", err);
return;
}
if (!process.env.WEB3_TOKEN) {
console.log("π ERROR:", "Create .env file");
return;
}
try {
const url = await uploadFile.web3(
{
token: process.env.WEB3_TOKEN,
},
{
hash: "banner",
ext: ".png",
buffer: data,
}
);
console.log("β
WEB3:", url);
await deleteFile.web3(
{
token: process.env.WEB3_TOKEN,
},
{
url,
}
);
} catch (err) {
console.log("π WEB3:", err);
}
});
fs.readFile(join(__dirname, "..", "banner.png"), async (err, data) => {
if (err) {
console.log("π ERROR:", err);
return;
}
if (!process.env.LIGHTHOUSE_TOKEN) {
console.log("π ERROR:", "Create .env file");
return;
}
try {
const url = await uploadFile.lighthouse(
{
token: process.env.LIGHTHOUSE_TOKEN,
},
{
hash: "banner",
ext: ".png",
buffer: data,
}
);
console.log("β
LIGHTHOUSE:", url);
await deleteFile.lighthouse(
{
token: process.env.LIGHTHOUSE_TOKEN,
},
{
url,
}
);
} catch (err) {
console.log("π LIGHTHOUSE:", err);
}
});
(c)
Alex Baker