Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRUD API (sort of) #8

Open
Bowarc opened this issue Jul 9, 2024 · 7 comments
Open

CRUD API (sort of) #8

Bowarc opened this issue Jul 9, 2024 · 7 comments

Comments

@Bowarc
Copy link
Owner

Bowarc commented Jul 9, 2024

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

  • GET / -> web_page
  • GET /<uuid> download file with given uuid
  • PUT / upload a file
  • more ?

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
Copy link
Owner Author

Bowarc commented Jul 9, 2024

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
Copy link
Owner Author

Bowarc commented Jul 10, 2024

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
Copy link
Owner Author

Bowarc commented Jul 10, 2024

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
Copy link
Owner Author

Bowarc commented Jul 11, 2024

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
Copy link
Owner Author

Bowarc commented Jul 11, 2024

But that wouldn't work w/ curl

@Bowarc
Copy link
Owner Author

Bowarc commented Aug 29, 2024

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
Copy link
Owner Author

Bowarc commented Aug 29, 2024

Now, we need to fix #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant