All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dtflys.forest.http.body.MultipartRequestBody Maven / Gradle / Ivy

There is a newer version: 1.6.1
Show newest version
package com.dtflys.forest.http.body;

import com.dtflys.forest.exceptions.ForestRuntimeException;
import com.dtflys.forest.http.ForestRequestBody;
import com.dtflys.forest.utils.ForestDataType;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

public class MultipartRequestBody extends ForestRequestBody {

    private MultipartFile multipartFile;

    public MultipartRequestBody(MultipartFile multipartFile) {
        this.multipartFile = multipartFile;
    }

    public MultipartFile getMultipartFile() {
        return multipartFile;
    }

    public void setMultipartFile(MultipartFile multipartFile) {
        this.multipartFile = multipartFile;
    }

    @Override
    public byte[] getByteArray() {
        try {
            return multipartFile.getBytes();
        } catch (IOException e) {
            throw new ForestRuntimeException(e);
        }
    }

    @Override
    public ForestDataType getDefaultBodyType() {
        return ForestDataType.MULTIPART;
    }

    @Override
    public MultipartRequestBody clone() {
        MultipartRequestBody newBody = new MultipartRequestBody(multipartFile);
        newBody.setDefaultValue(getDefaultValue());
        return newBody;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy