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
Project ID:
N/A
N/A
Hey @Brody are you still online?
When trying to upload more than one file, I get the following:
how long did the upload run for? railway has a max POST time of 5 minutes
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
oh then you wouldn't be running into the 5 minute POST request time limit
this would just be some issue with your app
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
yeah thats a good enough way to do it just for test purposes
copy
so the volume feature supports this? No need to rename with every new upload?
yeah you can overwrite files
any error logs?
I am getting this actually...
Error: ENOENT: no such file or directory, stat '/part_files/test.stl'
i assume the volume mount is /part_files right?
correct
wanna double check that for me? it would be in the volumes settings
can you show me your bb.extend function
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);
That is within a router.post method
correct
okay ill see if i can whip up some example code using busboy
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
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_atanasovHey 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
the POST didn't work because you didn't use POST lol, please make sure you use https as well
(what is SF?)
San Francisco probably
oh then no, I'm EST and it was only 12:43 when I sent that message asking to test the endpoints
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)
theres no file fields in that form lol
my code is crude, theres no validation on if your request has files or not
<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 visYeah my bad
it works 👍
are you aware of a tool called postman
This? https://www.postman.com
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.
yes
Never used it
you really should
so have you tested all endpoints
All but the delete
Because I couldnt do that via <form>
Everything else works though
thats what postman is for
I figured
I just downloaded it
all good?
yes
are you still intrested in the code?
Yes please. It would be great for reference!
Thank you very much for the support!
no problem, let me know if you need anything else