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
63 stars 7 forks source link

No properties of the uploaded file #4

Closed GreenBabyBorn closed 3 months ago

GreenBabyBorn commented 4 months ago

No properties of the uploaded file

export default defineEventHandler(async (event) => {
    const { file } = await readBody<{ file: File }>(event)

    await storeFileLocally(
        file.content, // the stringified version of the file
        file.name,    // UNDEFINED
        '/userFiles'  // the folder the file will be stored in
    )

    // {OR}

    // Parses a data URL and returns an object with the binary data and the file extension.
    const { binaryString, ext } = parseDataUrl(file.content)

    return 'success!'
})

interface File {
    name: string
    content: string
}
NyllRE commented 4 months ago

good notice, I'll make sure the library provides the properties soon enough

puzzle-it-nu commented 4 months ago

Hi,

good notice, I'll make sure the library provides the properties soon enough I just ran into the same problem and would like the have access to the extra properties like name, size, mime-type and whatever is appropriate.

Nice work though. I wrote an express-multer uploader a while ago and was wondering whether to use that in Nuxt when I found your module.

bitsnaps commented 3 months ago

I'm getting a similar error:

Failed to fetch dynamically imported module: http://localhost:3000/_nuxt/pages/index.vue?t=1716749037808

I'm not sure if I can use nuxt-file-storage module to save a generated image to the disk?

NyllRE commented 3 months ago

@bitsnaps please provide a reproduction using Stackblitz. write in the same code that resulted in this issue

bitsnaps commented 3 months ago

@bitsnaps please provide a reproduction using Stackblitz. write in the same code that resulted in this issue

My bad, I had to run that code from an event handler on server side, I solved my issue by using fs module instead.

fir3bird commented 3 months ago

Seems like that should be fixed now with v0.2.3, but unfortunately the official npm registry seems to still have an old version. Even if my package-lock and package version is at v.0.2.3 the newest changes are not in it...

NyllRE commented 3 months ago

@fir3bird oops, seems like I might have forgot to push the updates before the version bump, I'll fix it

u5r0 commented 3 months ago

Hello, thanks for the good work!

While waiting for this, Is there a way for data retrieval?

Thanks again

NyllRE commented 3 months ago

I have just updated the package to include all of the fixes, let me know if there's anything else not working, thanks for using and supporting my package!