FoalTS / foal

Full-featured Node.js framework 🚀
https://foalts.org/
MIT License
1.9k stars 142 forks source link

file metadata info while upload #673

Closed sumanadak closed 4 years ago

sumanadak commented 4 years ago

Could someone please help with this. how do I get the original file name, file size, mime type while uploading a file? I tried this @ValidateMultipartFormDataBody({ files: { photo: { required: true, saveTo: 'photos' } } }) uploadPhoto(ctx: Context) { console.log(ctx.request.body) const { path } = ctx.request.body.files.photo; } I only get the path here. Does it mean, I have send all other meta info through non-binary fields?

Help is much appreciated.

Thanks Suman

anonimusprogramus commented 4 years ago

Not an answer, just prettifying the code :smile:

@ValidateMultipartFormDataBody({
  files: {
    photo: { required: true, saveTo: 'photos' }
  }
})

uploadPhoto(ctx: Context) {
  console.log(ctx.request.body)
  const { path } = ctx.request.body.files.photo;
}
LoicPoullain commented 4 years ago

Thks @anonimusprogramus

It is currently not possible to access the original file name, file size, mime type at the moment. But this is something that will be probably added in the future.

Does it mean, I have send all other meta info through non-binary fields?

For the moment, yes.

LoicPoullain commented 4 years ago

Feature added in v2.0. It will be released between June and August.

sumanadak commented 4 years ago

Thanks a lot for your work.

Thanks Suman

On Fri, 29 May, 2020, 12:57 PM Loïc Poullain, notifications@github.com wrote:

Feature added in v2.0. It will be released between June and August.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FoalTS/foal/issues/673#issuecomment-635809638, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEZL26DO6E7IJVI7J6I4U3RT5PWXANCNFSM4MEDCZ3Q .