Wednesday, 19 April 2017

Should serving static image files be RESTfull?

I have a app that shows listings and each listing as jpeg pics.

If a user wanted to delete a picture from a listing they posted I have DELETE /listings/:listingID/images/image-filename.jpeg

The images are on my filesystem in a directory called /listing-pics. I have a structure that is easiest to organize by /listing-pics/user-id/listing-id/image-filename.

I have express serve these files with:

 app.use('/listing-pics', express.static('listing-pics'));

and it works great. When a listing shows, it grabs it's images with http://12.1.3.4:9000/listing-pics/3/2/image-3-2-1492486765428.jpeg.

But now I am wondering, for proper conventions do I need to make these static image files being served RESTfull? And if so, how would that play into app.use('/listing-pics', express.static('listing-pics'));?



via dman

No comments:

Post a Comment