mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-03 13:19:16 -05:00
fixed image import in URL import
This commit is contained in:
@@ -48,11 +48,20 @@ export function useFileApi() {
|
||||
})
|
||||
}
|
||||
|
||||
function updateRecipeImage(recipeId: number, file: File|null){
|
||||
/**
|
||||
* update a recipes image either by a given file or given url
|
||||
* @param recipeId ID of recipe to update
|
||||
* @param file file object to upload or null to delete image (if no imageUrl is given)
|
||||
* @param imageUrl url of an image to download by server
|
||||
*/
|
||||
function updateRecipeImage(recipeId: number, file: File|null, imageUrl?: string){
|
||||
let formData = new FormData()
|
||||
if (file != null) {
|
||||
formData.append('image', file)
|
||||
}
|
||||
if (imageUrl) {
|
||||
formData.append('image_url', imageUrl)
|
||||
}
|
||||
|
||||
return fetch(getDjangoUrl(`api/recipe/${recipeId}/image/`), {
|
||||
method: 'PUT',
|
||||
|
||||
Reference in New Issue
Block a user