diff --git a/.env.example b/.env.example index f95560c..ff707c7 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,7 @@ FILE_UPLOAD_SERVICE= +IMAGEKIT_ENDPOINT= +IMAGEKIT_PUBLIC_KEY= +IMAGEKIT_PRIVATE_KEY= LINK_PREVIEW_SERVICE= RPC_CUSTOM= SPHERON_BUCKET_NAME= diff --git a/README.md b/README.md index aa1be54..4342c48 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,18 @@ SPHERON_STORAGE_TOKEN= Image uploads via Spheron work only if you have Netlify/Vercel background functions enabled (see `netlify/functions/imageUploader.js`). +## Image upload fallback + +It is recommended to use ImageKit as the fallback option, in case Spheron has technical issues. + +For this to work, create an account at [ImageKit.io](https://imagekit.io/) and add these environment variables to your project: + +```bash +IMAGEKIT_ENDPOINT= +IMAGEKIT_PUBLIC_KEY= +IMAGEKIT_PRIVATE_KEY= +``` + ## Customize - Project-specific settings in `nuxt.config.ts` diff --git a/api/imageUploaderFallback.js b/api/imageUploaderFallback.js new file mode 100644 index 0000000..18dbd9f --- /dev/null +++ b/api/imageUploaderFallback.js @@ -0,0 +1,18 @@ +const ImageKit = require("imagekit"); + +export default async function handler(request, response) { + try { + const imagekit = new ImageKit({ + urlEndpoint: process.env.IMAGEKIT_ENDPOINT, + publicKey: process.env.IMAGEKIT_PUBLIC_KEY, + privateKey: process.env.IMAGEKIT_PRIVATE_KEY + }) + + return response.status(200).json({ + data: imagekit.getAuthenticationParameters() + }); + } catch (error) { + console.error(error); + next(error); + } +} \ No newline at end of file diff --git a/components/storage/FileUploadInput.vue b/components/storage/FileUploadInput.vue index 4dee6ba..df5e8f5 100644 --- a/components/storage/FileUploadInput.vue +++ b/components/storage/FileUploadInput.vue @@ -23,6 +23,7 @@