-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uploads power station images to ImgKit.io
- Loading branch information
1 parent
08519b4
commit f886e7d
Showing
7 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
AIRTABLE_API_KEY=https://airtable.com/create/tokens | ||
GOOGLE_MAPS_API_KEY=https://console.developers.google.com/apis/credentials | ||
URL=http://localhost:3000 | ||
URL=http://localhost:3000 | ||
IMGKIT_PRIVATE_KEY=Base64 encoded private key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export const uploadToImgKit = ( | ||
file: string, | ||
fileName: string, | ||
folder: string | ||
) => { | ||
const url = "https://upload.imagekit.io/api/v2/files/upload"; | ||
const form = new FormData(); | ||
form.append("file", file); | ||
form.append("fileName", fileName); | ||
form.append("folder", folder); | ||
form.append("useUniqueFileName", "false"); | ||
|
||
const options = { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Basic ${process.env.IMGKIT_PRIVATE_KEY}` as string, | ||
Accept: "application/json", | ||
}, | ||
body: form, | ||
}; | ||
|
||
try { | ||
fetch(url, options).catch((error) => console.error("error", error)); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; |