当前位置: 首页>>代码示例>>Java>>正文


Java Configuration类代码示例

本文整理汇总了Java中com.qiniu.storage.Configuration的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Configuration类属于com.qiniu.storage包,在下文中一共展示了Configuration类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configUploadEnv

import com.qiniu.storage.Configuration; //导入依赖的package包/类
/**
 * 配置文件上传环境
 */
public boolean configUploadEnv(String zone, String bucket) {
	if (!checkNet()) {
		Platform.runLater(() -> {
			Dialogs.showError(Values.NET_ERROR);
			System.exit(0);
		});
		return false;
	}
	logger.info("config file upload environment");
	// 构造一个带指定Zone对象的配置类
	Configuration configuration = new Configuration(QiniuApplication.zone.get(zone));
	// 生成上传凭证,然后准备上传
	String localTempDir = Paths.get(QiniuApplication.workDir, bucket).toString();
	try {
		FileRecorder fileRecorder = new FileRecorder(localTempDir);
		QiniuApplication.uploadManager = new UploadManager(configuration, fileRecorder);
	} catch (IOException e1) {
		logger.error("load local temp directory failed, can't use file recorder");
		QiniuApplication.uploadManager = new UploadManager(configuration);
	}
	QiniuApplication.configuration = configuration;
	QiniuApplication.bucketManager = new BucketManager(QiniuApplication.auth, configuration);
	return true;
}
 
开发者ID:zhazhapan,项目名称:qiniu,代码行数:28,代码来源:QiConfiger.java

示例2: loadProperties

import com.qiniu.storage.Configuration; //导入依赖的package包/类
/**
 * 加载配置文件并配置密钥()
 */
public static void loadProperties() throws MythException {
    InputStream in = QiNiuCloud.class.getClassLoader().getResourceAsStream("qiniu.properties");
    Properties pro = new Properties();
    try{
        pro.load(in);//加载配置文件
    }catch(IOException e){
        throw new MythException(PROPERTIES_EXCEPTION,e,QiNiuCloud.class);
    }
    accessKey = pro.getProperty("accessKey");//加载ACCESS_KEY
    secretKey = pro.getProperty("secretKey");//加载SECRET_KEY
    bucketName = pro.getProperty("bucketName");//加载要上传的空间名
    qiniuLink = pro.getProperty("qiniuLink");//加载七牛空间外链
    auth = Auth.create(accessKey, secretKey);//密钥配置
    zone = Zone.autoZone();//指定上传的Zone的信息
    config = new Configuration(zone);
}
 
开发者ID:Kuangcp,项目名称:JavaToolKit,代码行数:20,代码来源:QiNiuCloud.java

示例3: afterPropertiesSet

import com.qiniu.storage.Configuration; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    Configuration cfg = new Configuration(Zone.zone0());
    cfg.connectTimeout=5000;
    cfg.responseTimeout=5000;
    cfg.writeTimeout=2000;
    auth = Auth.create(accessKey, secretKey);
    uploadManager = new UploadManager(cfg);
    // 实例化一个BucketManager对象
    bucketManager = new BucketManager(auth, cfg);

    new Thread() {
        public void run() {
            deleteBlockingDequeImage();
        }
    }.start();
}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:18,代码来源:QiNiuUtil.java

示例4: QiniuProvider

import com.qiniu.storage.Configuration; //导入依赖的package包/类
public QiniuProvider(String urlprefix, String bucketName, String accessKey, String secretKey,boolean isPrivate) {
	
	Validate.notBlank(bucketName, "[bucketName] not defined");
	Validate.notBlank(accessKey, "[accessKey] not defined");
	Validate.notBlank(secretKey, "[secretKey] not defined");
	Validate.notBlank(urlprefix, "[urlprefix] not defined");
	
	this.urlprefix = urlprefix.endsWith(DIR_SPLITER) ? urlprefix : urlprefix + DIR_SPLITER;
	this.bucketName = bucketName;
	auth = Auth.create(accessKey, secretKey);

	Zone z = Zone.autoZone();
	Configuration c = new Configuration(z);
	uploadManager = new UploadManager(c);
	bucketManager = new BucketManager(auth,c);
	
	this.isPrivate = isPrivate;
}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:19,代码来源:QiniuProvider.java

示例5: load

import com.qiniu.storage.Configuration; //导入依赖的package包/类
public void load() {
    cfg = new Configuration(Zone.autoZone());
    auth = Auth.create(Config.getInstance().getQiniuAccessKey(),
            Config.getInstance().getQiniuSecretKey());
    bucketManager = new BucketManager(auth, cfg);
    uploadManager = new UploadManager(cfg);

    uploadData = new HashMap<>();
    uploadPool = Executors.newFixedThreadPool(10);
}
 
开发者ID:cmlanche,项目名称:javafx-qiniu-tinypng-client,代码行数:11,代码来源:QiniuManager.java

示例6: upload

import com.qiniu.storage.Configuration; //导入依赖的package包/类
/**
 * 上传图片到七牛云
 */
public static String upload(InputStream is){
    //构造一个带指定Zone对象的配置类
    Configuration cfg = new Configuration(Zone.zone0());
    //...其他参数参考类注释
    UploadManager uploadManager = new UploadManager(cfg);
    //...生成上传凭证,然后准备上传
    String accessKey = "vuQFyN34wj9OjD3P_iy4vUsJVSE_VaaOOf0damQ4";
    String secretKey = "2TfV9P_Jz4Wj415OaN4ErAADskCA0U-WBiFP52VW";
    String link = "http://omoitwcai.bkt.clouddn.com/";
    String bucket = "zhizhonghwang-pic";
    //默认不指定key的情况下,以文件内容的hash值作为文件名
    String key = null;
    try {
        Auth auth = Auth.create(accessKey, secretKey);
        String upToken = auth.uploadToken(bucket);
        Response response = uploadManager.put(is, key, upToken, null, null);
        //解析上传成功的结果
        DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
        link = link+putRet.hash;
    } catch (QiniuException ex) {
        Response r = ex.response;
        System.err.println(r.toString());
        link = "http://omoitwcai.bkt.clouddn.com/2017-07-21-%E9%BB%98%E8%AE%A4.jpg";
        try {
            System.err.println(r.bodyString());
        } catch (QiniuException ex2) {
            //ignore
        }
    }
    return link;
}
 
开发者ID:SCU-Newest,项目名称:Newest-Server,代码行数:35,代码来源:Functions.java

示例7: qiniuUpload

import com.qiniu.storage.Configuration; //导入依赖的package包/类
public static String qiniuUpload(String filePath){

        //构造一个带指定Zone对象的配置类 zone2华南
        Configuration cfg = new Configuration(Zone.zone2());

        UploadManager uploadManager = new UploadManager(cfg);

        String localFilePath = filePath;
        //默认不指定key的情况下,以文件内容的hash值作为文件名
        String key = null;
        Auth auth = Auth.create(accessKey, secretKey);
        String upToken = auth.uploadToken(bucket);

        try {
            Response response = uploadManager.put(localFilePath, key, upToken);
            //解析上传成功的结果
            DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
            return origin+putRet.key;
        }catch(QiniuException ex){
            Response r = ex.response;
            log.warn(r.toString());
            try {
                log.warn(r.bodyString());
                return r.bodyString();
            } catch (QiniuException ex2) {
                //ignore
            }
        }
        return null;
    }
 
开发者ID:Exrick,项目名称:xmall,代码行数:31,代码来源:QiniuUtil.java

示例8: QiniuProvider

import com.qiniu.storage.Configuration; //导入依赖的package包/类
public QiniuProvider(String urlprefix, String bucketName, String accessKey, String secretKey) {
    this.urlprefix = urlprefix.endsWith(DIR_SPLITER) ? urlprefix : urlprefix + DIR_SPLITER;
    this.bucketName = bucketName;
    auth = Auth.create(accessKey, secretKey);

    Zone z = Zone.autoZone();
    Configuration c = new Configuration(z);
    uploadManager = new UploadManager(c);
    bucketManager = new BucketManager(auth, c);
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:11,代码来源:QiniuProvider.java

示例9: getUrl

import com.qiniu.storage.Configuration; //导入依赖的package包/类
public static String getUrl(String filePath){
    String accessKey = "7td20cUlG7ws09BauAA9XXljJHJGx9ynEZYaRrTx";
    String secretKey = "nXD2rtQcHMHNxD4_sVDWrlodYhXW59XCuIDu9xiQ";
    String bucket = "photoscript";
    String cname = "http://owh91v0g1.bkt.clouddn.com/";
    Configuration cfg = new Configuration(Zone.zone0());
    UploadManager uploadManager = new UploadManager(cfg);


    Auth auth = Auth.create(accessKey, secretKey);
    String upToken = auth.uploadToken(bucket);
    String url = null;

    try {
        Response response = uploadManager.put(filePath, null, upToken);
        //解析上传成功的结果
        DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
        url = cname+putRet.key;
    } catch (QiniuException ex) {
        Response r = ex.response;
        System.err.println(r.toString());
        try {
            System.err.println(r.bodyString());
        } catch (QiniuException ignored) {
        }
    }

    return url;
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:30,代码来源:PictureUploadUtil.java

示例10: init

import com.qiniu.storage.Configuration; //导入依赖的package包/类
private void init(){
    uploadManager = new UploadManager(new Configuration(Zone.autoZone()));
    token = Auth.create(config.getQiniuAccessKey(), config.getQiniuSecretKey()).
            uploadToken(config.getQiniuBucketName());
}
 
开发者ID:zhaoqicheng,项目名称:renren-fast,代码行数:6,代码来源:QiniuCloudStorageService.java

示例11: init

import com.qiniu.storage.Configuration; //导入依赖的package包/类
private void init() {
    uploadManager = new UploadManager(new Configuration(Zone.autoZone()));
    token = Auth.create(config.getQiniuAccessKey(), config.getQiniuSecretKey()).
            uploadToken(config.getQiniuBucketName());
}
 
开发者ID:davichi11,项目名称:my-spring-boot-project,代码行数:6,代码来源:QiniuAbstractCloudStorageService.java

示例12: uploadResource

import com.qiniu.storage.Configuration; //导入依赖的package包/类
/**
 * 上传资源的最主要方法
 * 参数依次的含义: 点播云空间名(对应portal-->点播空间左上角的名字),失效时间,上传文件类型(参考文档),要上传的文件路径(最好用绝对路径)
 * StringMap (params参数)可以put进  key, crc32, x:vod, accept, xvod  这些值进去
 */
public Map<String, Object> uploadResource(String hub, int deadline, String type, String path, Map<String, Object> params) {
    if (type == null || type.length() <= 0) {
        type = "video";
    }

    UptokenRet uptokenRet = getVodUptokenV2(hub, deadline, type);
    // 判空,能否获取token
    if (uptokenRet == null) {
        System.err.println("cann't get vod uptoken");
        return null;
    }

    Configuration cf = new Configuration(Zone.autoZone());

    // 创建上传对象
    UploadManager uploadManager = new UploadManager(cf);

    Map<String, Object> ret = new HashMap<String, Object>();
    try {
        // key 参数为空,则用uptokenRet里的key
        String k = uptokenRet.getKey();
        if (params.containsKey("key")) {
            k = params.get("key").toString();
            params.remove("key");
        }

        boolean checkCrc=false;
        if (params.containsKey("crc32")){
            checkCrc=(Boolean) params.get("crc32");
            params.remove("crc32");
        }

        // 调用put方法上传
        StringMap qparams=new StringMap();
        qparams.putAll(params);
        Response res=uploadManager.put(path,k,uptokenRet.getUptoken(),qparams,null,checkCrc);

        // 打印返回的信息
        System.out.println(res.bodyString());

        StringMap retMap = res.jsonToMap();

        ret.put("code", res.statusCode);
        ret.put("hash", retMap.get("hash"));
        ret.put("key", retMap.get("key"));

    } catch (QiniuException e) {
        Response r = e.response;
        // 请求失败时,返回错误码,由客户自己根据错误码,在前端显示相应的提示信息
        ret.put("code", r.statusCode);
        ret.put("msg", r.toString());  // 错误信息
        System.err.printf("upload file error:%s",e.toString());
    }
    return ret;
}
 
开发者ID:qiniu-jedi,项目名称:jedi-java-sdk,代码行数:61,代码来源:UploadRes.java


注:本文中的com.qiniu.storage.Configuration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。