BAEL-5942 Code changes (#13147)

* BAEL-5942 Code changes

* BAEL-5942 Code changes

* BAEL-5942 Code updates from Review

* BAEL-5942 Code updates from Review

* BAEL-5942 Code updates from Review

* BAEL-5942 Code updates from Review

* BAEL-5942 Code updates from Review

* BAEL-5942 Code updates from Review

* BAEL-5942 Test updates from Review

* BAEL-5942 Test updates from Review

* BAEL-5942 Test updates from Review
This commit is contained in:
brokenhardisk
2023-01-22 12:48:56 +01:00
committed by GitHub
parent 42d27a6bfe
commit 506125b060
7 changed files with 189 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
package com.baeldung;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -0,0 +1,60 @@
package com.baeldung.file;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.springframework.web.multipart.MultipartFile;
public class CustomMultipartFile implements MultipartFile {
private byte[] input;
public CustomMultipartFile(byte[] input) {
this.input = input;
}
@Override
public String getName() {
return null;
}
@Override
public String getOriginalFilename() {
return null;
}
@Override
public String getContentType() {
return null;
}
@Override
public boolean isEmpty() {
return input == null || input.length == 0;
}
@Override
public long getSize() {
return input.length;
}
@Override
public byte[] getBytes() throws IOException {
return input;
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(input);
}
@Override
public void transferTo(File destination) throws IOException, IllegalStateException {
try(FileOutputStream fos = new FileOutputStream(destination)) {
fos.write(input);
}
}
}