Bowarc / storage_server

A simple cdn that compresses the data
1 stars 0 forks source link

CRUD API (sort of) #8

Open Bowarc opened 1 month ago

Bowarc commented 1 month ago

This makes reference of #6 and #7.

I want to rework the api system to use the request type to decide what action you wanna make.

The goal api would be

For the GET /<uuid> i wondered how i could make the browser ask the user for file save instead of displaying the file as content, and i found ! You just need to set Bytes or Binary as content type !!

Bowarc commented 1 month ago

For the download part, as for the filename you need the url to be /<id>/<filename> for the browser to download as filename which i don't like (as it adds more complexity and potential attack vector) my idea would be to use an html <a download></a>. But that requires to have a href tag to point to an actual url of the server where the file is served. Which i can, but meh

Another potential solution would be to pass the file content as the src part of the a tag ? If that is even possible. That would limit the server calls to 1.

Bowarc commented 1 month ago

Could a route of /<id> that would get the filename and redirect to /<id>/<filename> do the job?

It's a redirection so it might break some implementations...

Bowarc commented 1 month ago

I tried redirections, it works well on browsers, but i have an issue on the curl method, in curl the -O option is bugged when used with -L .

Welp Sadge

I mean, you can still normally -o but you would have to know the file name or come up with one yourself

Bowarc commented 1 month ago

My idea would be to use an html <a download></a>. But that requires to have a href tag to point to an actual url of the server where the file is served.

Needs to be tested.

Could be a solution

GET /<uuid> would give a webpage which would download /GET/<uuid>/<filename>

Bowarc commented 1 month ago

But that wouldn't work w/ curl

Bowarc commented 1 week ago

GET /<uuid> redirects, GET /<uuid>/<wrong file name> returns an error message with the correct file name in the text GET /<uuid>/<file name> returns the cache content

Bowarc commented 1 week ago

Now, we need to fix #3