R
Railway17mo ago
Nico

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

After uploading a single file, further files result in 'server unexpectedly dropped connection'.
52 Replies
Percy
Percy17mo ago
Project ID: N/A
Nico
NicoOP17mo ago
N/A Hey @Brody are you still online? When trying to upload more than one file, I get the following:
Nico
NicoOP17mo ago
Brody
Brody17mo ago
how long did the upload run for? railway has a max POST time of 5 minutes
Nico
NicoOP17mo ago
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:
Nico
NicoOP17mo ago
Nico
NicoOP17mo ago
FIle is ~500KB, so should be a very quick upload
Brody
Brody17mo ago
oh then you wouldn't be running into the 5 minute POST request time limit this would just be some issue with your app
Nico
NicoOP17mo ago
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
Brody
Brody17mo ago
yeah thats a good enough way to do it just for test purposes
Nico
NicoOP17mo ago
copy so the volume feature supports this? No need to rename with every new upload?
Brody
Brody17mo ago
yeah you can overwrite files any error logs?
Nico
NicoOP17mo ago
I am getting this actually... Error: ENOENT: no such file or directory, stat '/part_files/test.stl'
Brody
Brody17mo ago
i assume the volume mount is /part_files right?
Nico
NicoOP17mo ago
correct
Brody
Brody17mo ago
wanna double check that for me? it would be in the volumes settings
Nico
NicoOP17mo ago
Brody
Brody17mo ago
can you show me your bb.extend function
Nico
NicoOP17mo ago
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);
Nico
NicoOP17mo ago
That is within a router.post method correct
Brody
Brody17mo ago
okay ill see if i can whip up some example code using busboy
Nico
NicoOP17mo ago
awesome - thank you! 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
Brody
Brody17mo ago
dont worry ill get you some example code 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 - @nick_atanasov
Nico
NicoOP17mo ago
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
Nico
NicoOP17mo ago
Brody
Brody17mo ago
the POST didn't work because you didn't use POST lol, please make sure you use https as well (what is SF?)
fad
fad17mo ago
San Francisco probably
Brody
Brody17mo ago
oh then no, I'm EST and it was only 12:43 when I sent that message asking to test the endpoints
Nico
NicoOP17mo ago
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)
Brody
Brody17mo ago
theres no file fields in that form lol my code is crude, theres no validation on if your request has files or not
Nico
NicoOP17mo ago
<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 @Brody for vis
Nico
NicoOP17mo ago
Yeah my bad it works 👍
Brody
Brody17mo ago
are you aware of a tool called postman
Nico
NicoOP17mo ago
Postman
Postman API Platform | Sign Up for Free
Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
Brody
Brody17mo ago
yes
Nico
NicoOP17mo ago
Never used it
Brody
Brody17mo ago
you really should so have you tested all endpoints
Nico
NicoOP17mo ago
All but the delete Because I couldnt do that via <form> Everything else works though
Brody
Brody17mo ago
thats what postman is for
Nico
NicoOP17mo ago
I figured
Brody
Brody17mo ago
Nico
NicoOP17mo ago
I just downloaded it
Brody
Brody17mo ago
all good?
Nico
NicoOP17mo ago
Nico
NicoOP17mo ago
yes
Brody
Brody17mo ago
are you still intrested in the code?
Nico
NicoOP17mo ago
Yes please. It would be great for reference!
Nico
NicoOP17mo ago
Thank you very much for the support!
Brody
Brody17mo ago
no problem, let me know if you need anything else
Want results from more Discord servers?
Add your server