package tech.easyflow.ai.easyagentsflow.filestorage;

import com.easyagents.flow.core.chain.Chain;
import com.easyagents.flow.core.filestoreage.FileStorage;
import com.easyagents.flow.core.node.BaseNode;
import org.springframework.stereotype.Component;
import tech.easyflow.ai.node.InputStreamFile;
import tech.easyflow.common.filestorage.FileStorageService;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.Map;

@Component(value = "tinyFlowFileStorage")
public class StorageImpl implements FileStorage {

    @Resource(name = "default")
    private FileStorageService fileStorageService;

    @Override
    public String saveFile(InputStream stream, Map<String, String> headers, BaseNode node, Chain chain) {
        return fileStorageService.save(new InputStreamFile(stream, headers));
    }
}
