#After uploading a file to volume, further files result in 'server unexpectedly dropped connection'.

82 messages · Page 1 of 1 (latest)

long field
#

After uploading a single file, further files result in 'server unexpectedly dropped connection'.

acoustic pineBOT
#

Project ID: N/A

upper scrollBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

long field
#

N/A

#

Hey @latent stream are you still online?

#

When trying to upload more than one file, I get the following:

latent stream
#

how long did the upload run for? railway has a max POST time of 5 minutes

long field
#

Oh gotcha

#

wait what does that mean haha

#

Like if it takes more than 5 min it will have an issue?

#

By the way, this is my flow:

#

FIle is ~500KB, so should be a very quick upload

latent stream
#

oh then you wouldn't be running into the 5 minute POST request time limit

#

this would just be some issue with your app

long field
#

FYI, I do this: const saveToLocation = path.join(process.env.RAILWAY_VOLUME_MOUNT_PATH + '/test.stl');

#

which is for every upload

#

So it would technically re-write the file everytime

#

works locally

latent stream
#

yeah thats a good enough way to do it just for test purposes

long field
#

copy

#

so the volume feature supports this? No need to rename with every new upload?

latent stream
#

yeah you can overwrite files

#

any error logs?

long field
#

I am getting this actually...

#

Error: ENOENT: no such file or directory, stat '/part_files/test.stl'

latent stream
#

i assume the volume mount is /part_files right?

long field
#

correct

latent stream
#

wanna double check that for me? it would be in the volumes settings

long field
latent stream
#

can you show me your bb.extend function

long field
#

`const fileParser = busboy({headers: req.headers});

fileParser.on('file', function(fieldname, file, filename, encoding, mimetype) {\
    const saveToLocation = path.join(process.env.RAILWAY_VOLUME_MOUNT_PATH + '/test.stl');
    file.pipe(fs.createWriteStream(saveToLocation));
    console.log('saved to file');    
})    

req.pipe(fileParser); `
latent stream
long field
#

That is within a router.post method

#

correct

latent stream
#

okay ill see if i can whip up some example code using busboy

long field
#

awesome - thank you!

long field
#

FYI - i dont think I was every actually uploading a file to the volume, I just thought I was. Therefore, whatever I am doing is working locally but fails to work via the railway volume

latent stream
#

dont worry ill get you some example code

latent stream
#

before i send the final code, test this out for me
upload files as form-data: POST: https://test-service2.up.railway.app/upload
list all files in upload directory: GET: https://test-service2.up.railway.app/list
delete a file: DELETE: https://test-service2.up.railway.app/delete?file=<filename>
return file: GET: https://test-service2.up.railway.app/files/<filename>

#

and a little tag for visibility - @long field

long field
#

Hey Brody - I ended heading to bed, Im in the CST time zone so it was a little later our here (assuming you are in SF).

#

The POST did not work

latent stream
#

the POST didn't work because you didn't use POST lol, please make sure you use https as well

#

(what is SF?)

glass spear
#

San Francisco probably

latent stream
#

oh then no, I'm EST and it was only 12:43 when I sent that message asking to test the endpoints

long field
#

I did this:

#

<form method="post" action="https://test-service2.up.railway.app/upload"> <input type="submit" name="submit" value="Submit using POST" /> </form>

#

and got the following result:

#

saved file(s)

latent stream
#

theres no file fields in that form lol

#

my code is crude, theres no validation on if your request has files or not

long field
#

<form method="post" action="https://test-service2.up.railway.app/list" enctype="multipart/form-data"> <div> <label for="file">Choose a file</label> <input type="file" id="file" name="myFile" /> </div> <div> <button>Send the file</button> </div> </form>

#

response:

#

Cannot POST /list

long field
#

@latent stream for vis

latent stream
long field
#

Yeah my bad

#

it works 👍

latent stream
#

are you aware of a tool called postman

long field
latent stream
#

yes

long field
#

Never used it

latent stream
#

you really should

#

so have you tested all endpoints

long field
#

All but the delete

#

Because I couldnt do that via <form>

#

Everything else works though

latent stream
#

thats what postman is for

long field
#

I figured

latent stream
long field
#

I just downloaded it

latent stream
#

all good?

long field
#

yes

latent stream
#

are you still intrested in the code?

long field
#

Yes please. It would be great for reference!

latent stream
long field
#

Thank you very much for the support!