[파일 업로드] tusHook 작업
- 진행중
This commit is contained in:
@@ -83,10 +83,21 @@ public class FileController {
|
||||
}
|
||||
|
||||
@PostMapping("/tusHook")
|
||||
public ResponseEntity<ApiResponse<String>> tusHook(@RequestBody Map<String, Object> payload) {
|
||||
public ResponseEntity<ApiResponse<String>> tusHook(@RequestBody TusHookForm tusHookForm) {
|
||||
// log.info("tusHookForm: {}", tusHookForm);
|
||||
// fileService.insertFileAndSave(tusHookForm.tusHookDto());
|
||||
log.info("[tusHook] payload={}", payload);
|
||||
log.info("[tusHook] type={}", tusHookForm.getType());
|
||||
log.info("[tusHook] uploadId={}", tusHookForm.getTusHookEventForm().getTusHookUploadForm().getId());
|
||||
log.info("[tusHook] size={}", tusHookForm.getTusHookEventForm().getTusHookUploadForm().getSize());
|
||||
log.info("[tusHook] metaData={}", tusHookForm.getTusHookEventForm().getTusHookUploadForm().getMetaData());
|
||||
|
||||
log.info("[tusHookDto] type={}", tusHookForm.tusHookDto().getType());
|
||||
log.info("[tusHookDto] uploadId={}", tusHookForm.tusHookDto().getUploadId());
|
||||
log.info("[tusHookDto] size={}", tusHookForm.tusHookDto().getSize());
|
||||
log.info("[tusHookDto] fileMasterKey={}", tusHookForm.tusHookDto().getFileMasterKey());
|
||||
log.info("[tusHookDto] filename={}", tusHookForm.tusHookDto().getFilename());
|
||||
log.info("[tusHookDto] filetype={}", tusHookForm.tusHookDto().getFiletype());
|
||||
|
||||
return ApiResponse.entity("", ApiResponseCode.CODE_200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.alist.api.common.modules.file.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class TusHookDto {
|
||||
private TusHookEventDto tusHookEventDto;
|
||||
private TusHookUploadDto tusHookUploadDto;
|
||||
private String type;
|
||||
private String uploadId;
|
||||
private Long size;
|
||||
private String fileMasterKey;
|
||||
private String filename;
|
||||
private String filetype;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.alist.api.common.modules.file.form;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class TusHookEventForm {
|
||||
@JsonProperty("Upload")
|
||||
private TusHookUploadForm tusHookUploadForm;
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.alist.api.common.modules.file.form;
|
||||
|
||||
import com.alist.api.common.modules.file.dto.TusHookDto;
|
||||
import com.alist.api.common.modules.file.dto.TusHookEventDto;
|
||||
import com.alist.api.common.modules.file.dto.TusHookUploadDto;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -11,14 +10,31 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class TusHookForm {
|
||||
private TusHookEventDto event;
|
||||
private TusHookUploadDto upload;
|
||||
@JsonProperty("Type")
|
||||
private String type;
|
||||
|
||||
@JsonProperty("Event")
|
||||
private TusHookEventForm tusHookEventForm;
|
||||
|
||||
public TusHookDto tusHookDto() {
|
||||
TusHookDto tusHookDto = new TusHookDto();
|
||||
tusHookDto.setTusHookEventDto(this.event);
|
||||
tusHookDto.setTusHookUploadDto(this.upload);
|
||||
TusHookDto dto = new TusHookDto();
|
||||
|
||||
return tusHookDto;
|
||||
dto.setType(this.type);
|
||||
|
||||
if (this.tusHookEventForm == null || this.tusHookEventForm.getTusHookUploadForm() == null) {
|
||||
return dto;
|
||||
}
|
||||
|
||||
TusHookUploadForm upload = this.tusHookEventForm.getTusHookUploadForm();
|
||||
dto.setUploadId(upload.getId());
|
||||
dto.setSize(upload.getSize());
|
||||
|
||||
if (upload.getMetaData() != null) {
|
||||
dto.setFileMasterKey(upload.getMetaData().get("fileMasterKey"));
|
||||
dto.setFilename(upload.getMetaData().get("filename"));
|
||||
dto.setFiletype(upload.getMetaData().get("filetype"));
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.alist.api.common.modules.file.form;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class TusHookUploadForm {
|
||||
@JsonProperty("ID")
|
||||
private String id;
|
||||
|
||||
@JsonProperty("Size")
|
||||
private Long size;
|
||||
|
||||
@JsonProperty("MetaData")
|
||||
private Map<String, String> metaData;
|
||||
}
|
||||
@@ -74,22 +74,6 @@ public class FileService {
|
||||
}
|
||||
|
||||
public void insertFileAndSave(TusHookDto tusHookDto) {
|
||||
if (tusHookDto == null || tusHookDto.getTusHookEventDto() == null || tusHookDto.getTusHookUploadDto() == null) {
|
||||
log.info("[tusHook] invalid payload");
|
||||
return;
|
||||
}
|
||||
|
||||
String eventType = tusHookDto.getTusHookEventDto().getType();
|
||||
TusHookUploadDto upload = tusHookDto.getTusHookUploadDto();
|
||||
Map<String, String> meta = upload.getMetaData();
|
||||
|
||||
String uploadId = upload.getId();
|
||||
Long size = upload.getSize();
|
||||
String fileMasterKey = meta == null ? null : meta.get("fileMasterKey");
|
||||
String filename = meta == null ? null : meta.get("filename");
|
||||
String filetype = meta == null ? null : meta.get("filetype");
|
||||
|
||||
log.info("[tusHook] eventType={}, uploadId={}, size={}, fileMasterKey={}, filename={}, filetype={}",
|
||||
eventType, uploadId, size, fileMasterKey, filename, filetype);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user