// Path: lolibox-server/src/main/java/io/loli/box/service/AbstractStorageService.java
// public abstract class AbstractStorageService implements StorageService {
//     @Autowired
//     protected ImgFileRepository imgFileRepository;
// 
//     public void deleteFile(String name) {
//         imgFileRepository.updateDeleteByShortName(name, true);
//     }
// 
//     @Override
//     public boolean deleteFile(String name, User user) {
//         ImgFile file = imgFileRepository.findByShortName(name);
//         if(file.getUser().getId().equals(user.getId())) {
//             return true;
//         } else {
//             return false;
//         }
//     }
// }


import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.model.ObjectMetadata;
import com.qcloud.cos.region.Region;
import io.loli.box.service.AbstractStorageService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.InputStream;
package io.loli.box.service.impl;



/**
 * 腾讯云cos存储服务
 */
@Component
@ConditionalOnProperty(name = "storage.type", havingValue = "cos")
@ConfigurationProperties(prefix = "storage.cos")
// Path: lolibox-server/src/main/java/io/loli/box/service/AbstractStorageService.java
// public abstract class AbstractStorageService implements StorageService {
//     @Autowired
//     protected ImgFileRepository imgFileRepository;
// 
//     public void deleteFile(String name) {
//         imgFileRepository.updateDeleteByShortName(name, true);
//     }
// 
//     @Override
//     public boolean deleteFile(String name, User user) {
//         ImgFile file = imgFileRepository.findByShortName(name);
//         if(file.getUser().getId().equals(user.getId())) {
//             return true;
//         } else {
//             return false;
//         }
//     }
// }


// Path: lolibox-server/src/main/java/io/loli/box/service/impl/CosStorageService.java
import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.model.ObjectMetadata;
import com.qcloud.cos.region.Region;
import io.loli.box.service.AbstractStorageService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.InputStream;

package io.loli.box.service.impl;



/**
 * 腾讯云cos存储服务
 */
@Component
@ConditionalOnProperty(name = "storage.type", havingValue = "cos")
@ConfigurationProperties(prefix = "storage.cos")
public class CosStorageService extends AbstractStorageService {