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