Drive - not getting size error

Hi.

I’m not getting the size error validation (at least).

This is my code:

OfferController.js

      const document = await request.file('document',{
        extnames: ['pdf'],
        size: '1mb'
      })

      const newDoc = await offer.storeDocument(document)

Offer.js

  async storeDocument(pdfFile){

    await this.documents().delete()

    const userProfile = await this.profile().first()

    const userId = userProfile.user_id

    const tempfolder = 'uploads/user_' + userId

    try{
      await pdfFile.move( Helpers.tmpPath(tempfolder), {
        overwrite: true
      })
    }catch(e){
      console.log(e);
    }

Although I upload a 2mb file I don’t get any error on the server console and the code continues.

But afterwards I move the file to it’s final folder with Drive and I get an error message that the document doesn’t exists.

return await Drive.move(tempFilePath,finalFilePath)
here I receive an error that the tempFilePath doesn’t exists:
message: "ENOENT: no such file or directory, stat '/.....pdf'"

What is wrong?

Does this directory exist? Maybe just uploads exist but not uploads/user_33 or similar

Hi @johandalabacka

No, the folder doesn’t exists. Drive will create it.

1 Like