I created a call to slack's api, but I'm getting no_file_data error, I've tested my file and it is being generated, I've sent it with filename in multiform, with filetype, but the error persists
CLASSE MICROPOFILE (client):
@Path("/slack")
@RegisterRestClient(configKey = "open-co.scd.integration.slack.api.scd-report-file")
@RegisterProvider(BaseExceptionMapper.class)
public interface SCDReportFileUploadClient {
@POST
@Path("/files.upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
Response sendFileUpload(
@MultipartForm SlackReportFileUploadRequest requestBody,
@HeaderParam("Authorization") String token);
}
CLASSE DO FORM:
public class SlackReportFileUploadRequest {
@FormParam("file")
@PartType(MediaType.APPLICATION_OCTET_STREAM)
private InputStream file;
@FormParam("channels")
@PartType(MediaType.TEXT_PLAIN)
private String channels;
@FormParam("filename")
private String fileName;
@FormParam("filetype")
private String fileType = "text";
public SlackReportFileUploadRequest() {}
public SlackReportFileUploadRequest(
InputStream file, String channels, String fileName, String fileType) {
this.file = file;
this.channels = channels;
this.fileName = fileName;
this.fileType = fileType;
}
public InputStream getFile() {
return file;
}
public void setFile(InputStream file) {
this.file = file;
}
public String getChannels() {
return channels;
}
public void setChannels(String channels) {
this.channels = channels;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
}
CLASSE REQUEST:
.
.
.
public Response sendFileReport(byte[] content, String fileName) throws IOException {
return fileUploadClient.sendFileUpload(requestBodySendFile(content, fileName, channels), token);
}
private SlackReportFileUploadRequest requestBodySendFile(
byte[] content, String fileName, String channels) throws IOException {
SlackReportFileUploadRequest buildForm = new SlackReportFileUploadRequest();
buildForm.setFile(new ByteArrayInputStream(content));
buildForm.setChannels(channels);
buildForm.setFileName(fileName);
return buildForm;
}
.
.
.
I need a generalist class that I can send files like .txt and .csv