NyllRE / nuxt-file-storage

Easy solution to store files in your nuxt apps. Be able to upload files from the frontend and recieve them from the backend to then save the files in your project.
https://nuxt.com/modules/nuxt-file-storage
MIT License
74 stars 10 forks source link

Trouble with mount variable on Vercel deployment #16

Closed alex-croitoriu closed 2 months ago

alex-croitoriu commented 2 months ago

I'm trying to get my nuxt project working on a Vercel deployment. Locally I am setting the MOUNT env variable according to my local file system and it works just fine. On Vercel however, I don't know what path I should configure for the mount variable for my app to work correctly. I don't know what the absolute path is supposed to be on a Vercel deployment.

NyllRE commented 2 months ago

try this: https://vercel.com/docs/build-output-api/v3/primitives

learn more about the file system in vercel from this link and let me know if everything worked properly

alex-croitoriu commented 2 months ago

Unfortunately I couldn't get it to work using nuxt-file-storage. I honestly don't even know if it can be done, Vercel probably won't let me access absolute paths outside of the .output folder. I resorted to using Vercel Blob, which does the job for me.

githubmeta commented 2 months ago

Unfortunately I couldn't get it to work using nuxt-file-storage. I honestly don't even know if it can be done, Vercel probably won't let me access absolute paths outside of the .output folder. I resorted to using Vercel Blob, which does the job for me.

It will be of great help if you can share with us the configuration settings for Vercel Blob usage.

alex-croitoriu commented 2 months ago

Sure, it's actually pretty straight forward. After you create your blob and connect it to your project on Vercel, you need to install the @vercel/blob dependency and copy the BLOB_READ_WRITE_TOKEN variable and put it in your .env file. That's all, after that you can upload files like this:

import { put } from "@vercel/blob";

const { url } = await put('articles/blob.txt', 'Hello World!', { access: 'public' });