nuxt-file-storage icon indicating copy to clipboard operation
nuxt-file-storage copied to clipboard

No properties of the uploaded file

Open GreenBabyBorn opened this issue 1 year ago • 2 comments

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
}

GreenBabyBorn avatar May 16 '24 14:05 GreenBabyBorn

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

NyllRE avatar May 17 '24 20:05 NyllRE

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.

puzzle-it-nu avatar May 18 '24 14:05 puzzle-it-nu

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?

bitsnaps avatar May 26 '24 18:05 bitsnaps

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

NyllRE avatar May 26 '24 19:05 NyllRE

@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.

bitsnaps avatar May 27 '24 08:05 bitsnaps

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...

fir3bird avatar May 30 '24 14:05 fir3bird

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

NyllRE avatar May 30 '24 16:05 NyllRE

Hello, thanks for the good work!

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

Thanks again

u5r0 avatar Jun 04 '24 08:06 u5r0

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!

NyllRE avatar Jun 04 '24 16:06 NyllRE