This commit is contained in:
@@ -49,4 +49,4 @@ async def get_image(name: str):
|
|||||||
file_path = STORAGE_DIR / name
|
file_path = STORAGE_DIR / name
|
||||||
if not file_path.exists():
|
if not file_path.exists():
|
||||||
raise HTTPException(status_code=404, detail="NotFoundImage")
|
raise HTTPException(status_code=404, detail="NotFoundImage")
|
||||||
return FileResponse(file_path)
|
return FileResponse(file_path, media_type="image/webp")
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ package com.drinkool.controller;
|
|||||||
|
|
||||||
import com.drinkool.services.FileService;
|
import com.drinkool.services.FileService;
|
||||||
import io.smallrye.mutiny.Uni;
|
import io.smallrye.mutiny.Uni;
|
||||||
import io.vertx.mutiny.core.buffer.Buffer;
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.ws.rs.GET;
|
import jakarta.ws.rs.GET;
|
||||||
import jakarta.ws.rs.POST;
|
import jakarta.ws.rs.POST;
|
||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
|
import java.io.File;
|
||||||
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||||
|
import org.jboss.resteasy.reactive.RestForm;
|
||||||
|
|
||||||
@Path("/api/file")
|
@Path("/api/file")
|
||||||
public class FileController {
|
public class FileController {
|
||||||
@@ -19,8 +20,8 @@ public class FileController {
|
|||||||
FileService fileService;
|
FileService fileService;
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
public Uni<Response> upload(Buffer body) {
|
public Uni<Response> upload(@RestForm File file) {
|
||||||
return fileService.upload(body);
|
return fileService.upload(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
package com.drinkool.services;
|
package com.drinkool.services;
|
||||||
|
|
||||||
import io.smallrye.mutiny.Uni;
|
import io.smallrye.mutiny.Uni;
|
||||||
import io.vertx.mutiny.core.buffer.Buffer;
|
|
||||||
import jakarta.ws.rs.GET;
|
import jakarta.ws.rs.GET;
|
||||||
import jakarta.ws.rs.POST;
|
import jakarta.ws.rs.POST;
|
||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
||||||
|
import org.jboss.resteasy.reactive.RestForm;
|
||||||
|
|
||||||
@RegisterRestClient(configKey = "file")
|
@RegisterRestClient(configKey = "file")
|
||||||
@Path("/")
|
@Path("/")
|
||||||
public interface FileService {
|
public interface FileService {
|
||||||
@POST
|
@POST
|
||||||
Uni<Response> upload(Buffer body);
|
Uni<Response> upload(@RestForm File file);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{name}")
|
@Path("/{name}")
|
||||||
|
|||||||
Reference in New Issue
Block a user