Skip to content

REST API: file uploads with resizing of images in foodshare points

chandi requested to merge api-uploads into master

part of #482 (closed)
related: #83 (closed), #45 (closed), #444 (closed), #375

What does this MR do?

it implements two new API endpoints

POST /api/uploads

uploads provided file to ./data/uploads/ in multiple sub folders (based on the UUID) to avoid having >1M files in the same directory and stores an entry in the database. additionally it strips of all EXIF data and rotates the image, if necessary

GET /api/uploads/{uuid}

Returns uploaded files based on their UUID. Images can be rescaled with width and height parameters.

FileUpload.vue

a file upload component with optional cropping

FileUploadVForm.vue

a wrapper for FileUpload which allows embedding it into a legacy v_form

Fairteiler picture

the picture for fairteiler uses now these new components & the uploads api

How confident are you it won't break things if deployed?

Seems to work on localhost, but needs more testing

caching for nginx

apply this on the production server: images@ea34fc58

I think it doesn't make sense to enable it in the dev environment

How to test

  1. Checkout branch locally
  2. Login as ambassador (userbot)
  3. Go to a food share point, for example select one from the region's list http://localhost:18080/?page=bezirk&bid=241&sub=fairteiler
  4. Go to the edit page of that FSP
  5. Upload a picture
  6. Go back to the FSP's page and see if the picture is shown
  7. Go back to the region's FSP list and see if the thumb picture is shown

TODO

  • check out
  • bring on top of master
  • see what works locally
  • do tests need fixing or fail they because it doesn't work
  • check comments below

Links to related issues

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • joined #foodsharing-beta channel at https://slackin.yunity.org
  • added an entry to CHANGELOG.md (description, merge request link, username(s))
Edited by Christian Walgenbach

Merge request reports