cookbook icon indicating copy to clipboard operation
cookbook copied to clipboard

Upload image with recipe creating / update instead of selecting it from nextcloud data

Open Teifun2 opened this issue 4 years ago • 8 comments

Is your feature request related to a problem? Please describe. I develop one of the mobile apps. I see the use-case that some people would like to create a new recipe with an image they just took / they are gone take at the moment. In this instances it would be good if the image would not need to be uploaded to nextcloud already.

Describe the solution you'd like It would be nice if it were possible to directly upload an image with the post request to create or edit a recipe. So that instead of providing the relative path to the image on nextcloud you provide the binary data of the image and it gets saved directly into the recipe folder / or if easier in some sort of cookbook upload folder.

Describe alternatives you've considered I could implement a 2 step recipe creation that first uploads the image and then automatically ads the path in the create / edit request.


Depends on #1126

Teifun2 avatar May 24 '21 14:05 Teifun2

How would you like the binary data to be sent in the same request as the main recipe data? base64 encoded?

I'd rather have a 2-step creation although we could first create the recipe without an image attached and then add a new API endpoint to add a (binary) image to an existing recipe. Would that work?

Before updating the API, I would suggest ironing out some wrinkles in the current API so that we can extend more easily. Would that work or is this more pressing?

christianlupus avatar Jun 29 '21 19:06 christianlupus

I uploaded an updated version of the API specs for discussion (and later implementation). It can be found here.

For simpler communication and discussion, one can use this URL to tweak the API definition.

The update of the API might be due soon but this enhancement here is only a minor update and can be incorporated with the other updates.

Any opinions on it?

christianlupus avatar Oct 01 '21 10:10 christianlupus

Ahh swagger looks nice :)

So what do you suggest? To already include the change?

Teifun2 avatar Oct 01 '21 13:10 Teifun2

My suggestion is as follows: we first decide on an API structure. Then we can work towards this based on the open API specs.

Once, we are ready with the API, we can implement it in the next version of the cookbook app. Regarding the refactoring of the API endpoints, I would think this can also be done later, so the 3rd party authors can start working on the new features. The renaming of the endpoints should be no problem later (with a period of deprecation and enough time to adopt to the changes).

So, the question would be off the new API endpoint will help you achieve your desired result to upload an image accordingly or not. If no, please be more specific, what needs to be changed. 😁

christianlupus avatar Oct 03 '21 22:10 christianlupus

Hi, I would like to ask what the status of this API change is. It would be great if we could upload images while creating a new recipe. Thanks both of you, and keep up the good work!

redtux avatar Dec 12 '21 17:12 redtux

I am just working to move the image management from the RecipeService class which is completely bloated into its own class. That should allow us to create the app endpoints quickly.

christianlupus avatar Dec 14 '21 21:12 christianlupus

This PR/issue depends on:

github-actions[bot] avatar Jul 28 '22 21:07 github-actions[bot]

Having done a lot of work on the api side and it's implementation into the aforementioned app from @Teifun2 I don't think the proposed post request on the image endpoint would be enough.

Clients might have spotty connectivity and this might lead to the recipe creation going through while the image upload (a potentially heavier task) might fail (the same applies to the recipe update process). Therefore I suggest to also add an optional field to the recipe create endpoint (currently named /api/v1/recipes). This could be an optional second parameter that doesn't need to be implemented into the Recipe object.

Also any update to the mentioned transition? Any idea on when we can expect this? I'd love to help but I'm not native in php :(

Leptopoda avatar Jan 24 '23 17:01 Leptopoda