package com.heyu.api.data.utils;

import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
 
public class CustomMultipartFile implements MultipartFile {
    private final String name;
    private final String originalFilename;
    private final String contentType;
    private final byte[] content;
 
    public CustomMultipartFile(String name, String originalFilename, String contentType, byte[] content) {
        this.name = name;
        this.originalFilename = originalFilename;
        this.contentType = contentType;
        this.content = content;
    }
 
    @Override
    public String getName() {
        return this.name;
    }
 
    @Override
    public String getOriginalFilename() {
        return this.originalFilename;
    }
 
    @Override
    public String getContentType() {
        return this.contentType;
    }
 
    @Override
    public boolean isEmpty() {
        return this.content.length == 0;
    }
 
    @Override
    public long getSize() {
        return this.content.length;
    }
 
    @Override
    public byte[] getBytes() throws IOException {
        return this.content;
    }
 
    @Override
    public InputStream getInputStream() throws IOException {
        return new ByteArrayInputStream(this.content);
    }
 
    @Override
    public void transferTo(java.io.File dest) throws IOException, IllegalStateException {
        throw new UnsupportedOperationException("Not implemented");
    }
}