3

I am trying to decide which way is more restful. Either:

POST /v1/files/uploads

With file multipart data in the body of the request.

Or should I specify the resource by filename when uploading?

POST /v1/files/uploads/foo.jpg

Which one do you prefer? I am leaning towards the second one but not sure what is the best practice in this instance.

1 Answer 1

2

Definitely the first one, I mean:

POST /files/uploads/

(v1 is removed deliberately, versioning should be done via headers) or even:

POST /files/

should be good enough to handle the file upload.

multipart/form-data content type should be used and file content along with file name should be passed in the form. Resource name can be considered as an ID and when creating a new resource you don't know the ID (in RESTful style) since it's generated by the server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.