package ru.soune.nocopy.service.file;

import org.springframework.web.multipart.MultipartFile;
import ru.soune.nocopy.dto.file.UploadProgressResponse;
import ru.soune.nocopy.entity.file.FileEntity;
import ru.soune.nocopy.entity.file.FileStatus;
import ru.soune.nocopy.entity.file.FileUploadSession;
import ru.soune.nocopy.exception.DuplicateImageException;

import java.io.IOException;
import java.nio.file.Path;

public interface FileUploadService {
    FileUploadSession initUpload(Long userId, String fileName,
                                 String fileType, String extension, String convertTo, long fileSize);

    void handleExpiredSession(FileUploadSession session);

    void cancelUpload(String uploadId);

    UploadProgressResponse uploadChunk(String uploadId, Integer chunkNumber, MultipartFile chunkFile, Integer findSimilar);

    UploadProgressResponse uploadPassportChunk(String uploadId, Integer chunkNumber, MultipartFile chunkFile,
                                               Long userId);

    UploadProgressResponse getUploadProgress(String uploadId);

    FileEntity completeFileProcessing(FileUploadSession session, FileStatus status);

    public void checkForDuplicatesSynchronously(String filePath)  throws IOException, DuplicateImageException;

    public Path downloadImageFromUrl(String urlString) throws IOException;
}
