// 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.qiniu.api.auth.AuthException;
import com.qiniu.api.auth.digest.Mac;
import com.qiniu.api.io.IoApi;
import com.qiniu.api.io.PutExtra;
import com.qiniu.api.io.PutRet;
import com.qiniu.api.rs.PutPolicy;
import com.qiniu.api.rs.RSClient;
import io.loli.box.service.AbstractStorageService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONException;
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;



/**
 * @author choco
 */
@Component
@ConditionalOnProperty(name = "storage.type", havingValue = "qiniu")
@ConfigurationProperties(prefix = "storage.qiniu")
// 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/QiniuStorageService.java
import com.qiniu.api.auth.AuthException;
import com.qiniu.api.auth.digest.Mac;
import com.qiniu.api.io.IoApi;
import com.qiniu.api.io.PutExtra;
import com.qiniu.api.io.PutRet;
import com.qiniu.api.rs.PutPolicy;
import com.qiniu.api.rs.RSClient;
import io.loli.box.service.AbstractStorageService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONException;
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;



/**
 * @author choco
 */
@Component
@ConditionalOnProperty(name = "storage.type", havingValue = "qiniu")
@ConfigurationProperties(prefix = "storage.qiniu")
public class QiniuStorageService extends AbstractStorageService {