package cn.reghao.oss.store.task.processor;

import cn.reghao.oss.store.model.vo.ObjectResult;
import cn.reghao.oss.store.service.ObjectNameService;
import cn.reghao.oss.api.rest.UploadFileRet;
import org.springframework.stereotype.Service;

/**
 * @author reghao
 * @date 2023-07-12 15:45:02
 */
@Service
public class DiskFileProcessor {
    private final ObjectNameService objectNameService;

    public DiskFileProcessor(ObjectNameService objectNameService) {
        this.objectNameService = objectNameService;
    }

    public UploadFileRet process(ObjectResult objectResult) {
        String objectName = objectResult.getObjectName();
        String objectId = objectResult.getObjectId();
        String objectUrl = objectNameService.getObjectUrl(objectName);
        return new UploadFileRet(objectId, objectUrl);
    }
}
