
com.qiniu.datasource.AliOssContainer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qsuits Show documentation
Show all versions of qsuits Show documentation
qiniu-suits is a efficient tools for qiniu api implemented by java8.
package com.qiniu.datasource;
import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.model.OSSObjectSummary;
import com.qiniu.common.SuitsException;
import com.qiniu.convert.OSSObjToMap;
import com.qiniu.convert.OSSObjToString;
import com.qiniu.interfaces.ITypeConvert;
import com.qiniu.persistence.FileSaveMapper;
import com.qiniu.persistence.IResultOutput;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class AliOssContainer extends OssContainer> {
private String accessKeyId;
private String accessKeySecret;
private ClientConfiguration clientConfig;
private String endpoint;
public AliOssContainer(String accessKeyId, String accessKeySecret, ClientConfiguration clientConfig, String endpoint,
String bucket, List antiPrefixes, Map prefixesMap, boolean prefixLeft,
boolean prefixRight, Map indexMap, int unitLen, int threads) {
super(bucket, antiPrefixes, prefixesMap, prefixLeft, prefixRight, indexMap, unitLen, threads);
this.accessKeyId = accessKeyId;
this.accessKeySecret = accessKeySecret;
this.clientConfig = clientConfig;
this.endpoint = endpoint;
}
@Override
public String getSourceName() {
return "aliyun";
}
@Override
protected ITypeConvert> getNewConverter() {
return new OSSObjToMap(indexMap);
}
@Override
protected ITypeConvert getNewStringConverter() throws IOException {
return new OSSObjToString(saveFormat, saveSeparator, rmFields);
}
@Override
protected IResultOutput getNewResultSaver(String order) throws IOException {
return order != null ? new FileSaveMapper(savePath, getSourceName(), order) : new FileSaveMapper(savePath);
}
@Override
protected ILister getLister(String prefix, String marker, String end) throws SuitsException {
return new AliLister(new OSSClient(endpoint, new DefaultCredentialProvider(accessKeyId, accessKeySecret),
clientConfig), bucket, prefix, marker, end, null, unitLen);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy