• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BosClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: putObject

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static void putObject(String bucketName,File file,String fileName) throws IOException{
	
	    BosClient client = getClient();
	    // 获取数据流
	    InputStream content = new FileInputStream(file);
		// 创建上传Object的Metadata
		ObjectMetadata meta = new ObjectMetadata();
		
		// 必须设置ContentLength
//		meta.setContentLength(file.length());
//		meta.setContentEncoding("UTF-8");
		
		// 上传Object.
		String objectKey=fileName;
		PutObjectResponse result = client.putObject(bucketName, objectKey, content, meta);
		content.close();
	}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:18,代码来源:BaiduBOS.java


示例2: init

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
@PostConstruct
public void init() {
    location = Enum.valueOf(StoreLocation.class, coreConfig.getValue("app.upload.file.store"));
    switch (location) {
        case Cloud: {
            apikey = coreConfig.getValue("bae.app.apikey");
            secretKey = coreConfig.getValue("bae.app.secretkey");
            bucket = coreConfig.getValue("bae.bcs.bucket");

            BosClientConfiguration config = new BosClientConfiguration();
            config.setCredentials(new DefaultBceCredentials(apikey, secretKey));
            config.setEndpoint(host);
            // config.setEndpoint(coreConfig.getValue("app.domain"));
            // 设置HTTP最大连接数为10
            config.setMaxConnections(10);
            bosClient = new BosClient(config);
            break;
        }
        case FastDFS: {
            fastdfsClient = FastdfsClientFactory.getFastdfsClient();
            break;
        }
    }
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:25,代码来源:AppFileUtils.java


示例3: BaiduBOSImpl

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public BaiduBOSImpl(BaiduBOSConfig baiduBOSConfig) {
	this.baiduBOSConfig = baiduBOSConfig;
	BosClientConfiguration config = new BosClientConfiguration();
	config.setCredentials(
			new DefaultBceCredentials(baiduBOSConfig.getAccessKeyId(), baiduBOSConfig.getAccessKeySecret()));
	config.setEndpoint(baiduBOSConfig.getEndPoint());
	bosClient = new BosClient(config);
}
 
开发者ID:MinsxCloud,项目名称:minsx-ccs,代码行数:9,代码来源:BaiduBOSImpl.java


示例4: getNativeClient

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T getNativeClient(Class<T> nativeClientClass) {
	if (!nativeClientClass.isInstance(BosClient.class)) {
		throw new NativeClientCastException(bosClient.getClass(), nativeClientClass);
	}
	return (T) bosClient;
}
 
开发者ID:MinsxCloud,项目名称:minsx-ccs,代码行数:9,代码来源:BaiduBOSImpl.java


示例5: initial

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
@Before
public void initial() {
	BosClientConfiguration config = new BosClientConfiguration();
	config.setEndpoint("http://su.bcebos.com");
    config.setCredentials(new DefaultBceCredentials("c93dd9d3411740419a0ff0f16cfce2fc", "c7244fc343a8474682663f0a31d4d798"));
    bosClient = new BosClient(config);
}
 
开发者ID:MinsxCloud,项目名称:minsx-ccs,代码行数:8,代码来源:BosTest.java


示例6: getClient

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static BosClient getClient(){
		 // 初始化一个BosClient
	    BosClientConfiguration config = new BosClientConfiguration();
//	    config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID,SECRET_ACCESS_KEY));
//	    config.setEndpoint(ENDPOINT);
	    config.setCredentials(new DefaultBceCredentials(DiaowenProperty.ACCESS_KEY_ID,DiaowenProperty.SECRET_ACCESS_KEY));
	    config.setEndpoint(DiaowenProperty.ENDPOINT);
	    BosClient client = new BosClient(config);
	    return client;
	}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:11,代码来源:BaiduBOS.java


示例7: getObject

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static InputStream getObject(String bucketName,String fileName){
	// 初始化OSSClient
	BosClient client = getClient();
	//client.getObject(new GetObjectRequest(bucketName, key),new File(filename));
	BosObject bosObject=client.getObject(bucketName, fileName);
	
	InputStream inputStream=bosObject.getObjectContent();
	
	 // 获取Object,返回结果为BosObject对象
	return inputStream;
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:12,代码来源:BaiduBOS.java


示例8: getObjectList

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static List<BosObjectSummary> getObjectList(String bucketName,String prefix,int endIndex,int maxKeys){
	

	// 初始化OSSClient
	BosClient client = getClient();

	// 构造ListObjectsRequest请求
	ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);

	// 递归列出目录下的所有文件
	listObjectsRequest.setPrefix(prefix);
	listObjectsRequest.setMaxKeys(maxKeys);

	
	
	// listObjectsRequest.setMarker("ueditor/jsp/upload/image/20150614/1434267568217077840.jpg");

	ListObjectsResponse listing = null;
	String nextMarker = null;

	// endIndex>maxKeys
	int pageNum = endIndex / maxKeys;
	for (int i = 0; i < pageNum; i++) {
		if (nextMarker != null) {
			listObjectsRequest.setMarker(nextMarker);
		}
		listing = client.listObjects(listObjectsRequest);
		nextMarker = listing.getNextMarker();
	}

	// 遍历所有Object
	List<BosObjectSummary> objectSummarys = listing.getContents();
	
	return objectSummarys;
	// 遍历所有CommonPrefix
	/*
	 * System.out.println("\nCommonPrefixs:"); for (String commonPrefix :
	 * listing.getCommonPrefixes()) { System.out.println(commonPrefix); }
	 */
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:41,代码来源:BaiduBOS.java


示例9: main

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    AppFileUtils utils = new AppFileUtils();
    utils.apikey = "e46c7e6c281a4d3da7545c685bb5db1c";
    utils.secretKey = "89d1c208bee145f49ca88ef1bbd12302";
    utils.bucket = "onegymbucket";
    utils.location = StoreLocation.Disk;
    BosClientConfiguration config = new BosClientConfiguration();
    config.setCredentials(new DefaultBceCredentials(utils.apikey, utils.secretKey));
    config.setEndpoint(host);
    // config.setEndpoint(coreConfig.getValue("app.domain"));
    // 设置HTTP最大连接数为10
    config.setMaxConnections(10);
    BosClient bosClient = new BosClient(config);
    // 构造ListObjectsRequest请求
    ListObjectsRequest listObjectsRequest = new ListObjectsRequest(utils.bucket);
    // 递归列出fun目录下的所有文件
    listObjectsRequest.setPrefix("static/uploadFiles/manager1/2015-11-12");
    ListObjectsResponse listing = bosClient.listObjects(listObjectsRequest);
    // 遍历所有Object
    System.out.println("Objects:");
    for (BosObjectSummary objectSummary : listing.getContents()) {
        System.out.println(objectSummary.getKey());
    }

    System.out.println(StringUtils.substringAfterLast("http://bj.bcebos.com/v1/onegymbucket/static/uploadFiles/manager1/2015-11-12/483bdc2b9ee8413d99e91293237615c9/ccc.jpg", "onegymbucket/"));

    String fileUrl = "http://10.87.13.157:9011/fileWeb/CSAOFWeb/魏总2修.jpg";
    URL url = new URL(FilenameUtils.getFullPath(fileUrl) + Encodes.urlEncode(getFileName(fileUrl)));
    String storeFile = "D:\\data\\files\\images\\oa\\news\\魏总2修1111111111111.jpg";
    FileUtils.copyURLToFile(url, new File(storeFile));
    utils.uploadCompressImage(new File(storeFile), 0.7f, "D:\\data\\files\\images\\oa\\news\\");
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:33,代码来源:AppFileUtils.java


示例10: main

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	    String ENDPOINT = "http://bj.bcebos.com";
	    BosClientConfiguration config = new BosClientConfiguration();
	    config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
	    config.setEndpoint(ENDPOINT);
	    BosClient client = new BosClient(config);	    
//	    File targetFile = new File("C:\\Users\\lenovo\\Desktop\\清华大学MBA.txt");
//	    String storePath = "/static/test/";
//	    putObject(client, targetFile, storePath);
//	    deleteObject(client, "http://bj.bcebos.com/v1/onegymbucket/static/test/aaa.jpg");
        //上传url文件
        String fileurl = "http://bj.bcebos.com/v1/onegymbucket/static/uploadFiles/manager1/2015-10-28/e082e0bfc93d40d29b62afd087ee9f88/logo.jpg";
        String uploadedUrl =uploadFromUrl(client, BUCKET, fileurl, AppFileUtils.getFileBaseName(fileurl), "/static/uploadFiles/");
        System.out.println("uploadedUrl is: "+uploadedUrl);
	}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:16,代码来源:BCE.java


示例11: putObject

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static void putObject(BosClient client,File targetFile, String storePath) throws FileNotFoundException{		
	storePath += targetFile.getName();
	ObjectMetadata meta = new ObjectMetadata();
	meta.setContentLength(targetFile.length());
	meta.setContentType(AppFileUtils.getContentType(targetFile.getAbsolutePath()));
	client.putObject(BUCKET, storePath, new FileInputStream(targetFile), meta);												
	String savePath = client.generatePresignedUrl(BUCKET, storePath, -1).toString()+"&responseContentDisposition=attachment";
   	int index = savePath.indexOf("?authorization");
   	savePath = savePath.substring(0, index);
   	System.out.println(savePath);
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:12,代码来源:BCE.java


示例12: listObject

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static void listObject(BosClient client){
    ListObjectsResponse listing = client.listObjects(BUCKET);
    // 遍历所有Object
    for (BosObjectSummary objectSummary : listing.getContents()) {
        System.out.println("ObjectKey: " + objectSummary.getKey());
    }
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:8,代码来源:BCE.java


示例13: deleteObject

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static void deleteObject(BosClient client, String fileUrl){
	String remoteUrl = Encodes.urlDecode(fileUrl);	
	try{
		String url = StringUtils.substringAfterLast(remoteUrl, BUCKET+"/");
		BosObject object = client.getObject(BUCKET, url);
		client.deleteObject(BUCKET, object.getKey());
	}catch(Exception e){
		e.printStackTrace();
	}
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:11,代码来源:BCE.java


示例14: uploadFromUrl

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public static String uploadFromUrl(BosClient bosClient, String bucket, String fileUrl, String fileName, String storePath){
    String savePath = null;
    HttpURLConnection conn = null;
    try{
        String urlStr = FilenameUtils.getFullPath(fileUrl)+Encodes.urlEncode(AppFileUtils.getFileName(fileUrl));
        URL url = new URL(urlStr);
        conn = (HttpURLConnection) url.openConnection();
        conn.setDoInput(true);
        conn.setRequestMethod(Constants.HTTPGET);
        conn.connect();
        storePath += fileName+AppFileUtils.getFileExtByContentType(conn.getHeaderField(Constants.CONTENT_TYPE));
        ObjectMetadata meta = new ObjectMetadata();
        meta.setContentLength(conn.getContentLengthLong());
        meta.setContentType(conn.getContentType());
        bosClient.putObject(bucket, storePath, conn.getInputStream(), meta);
        savePath = bosClient.generatePresignedUrl(bucket, storePath, -1).toString()+"&responseContentDisposition=attachment";
        int index = savePath.indexOf("?authorization");
        savePath = savePath.substring(0, index);
        conn.disconnect();
    } catch(Exception e){
        if(conn != null){
            conn.disconnect();
            conn = null;
        }
        savePath = null;
    }finally{
        if(conn != null){
            conn.disconnect();
            conn = null;
        }
    }
    if(StringUtils.isNotEmpty(savePath)) {
        savePath = StringUtils.replace(savePath, Constants.SEPARATOR, "/");
    }
    return savePath;
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:37,代码来源:BCE.java


示例15: initialize

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
@PostConstruct
private void initialize() {
  this.bucket = configuration.getBucket();
  BosClientConfiguration config = new BosClientConfiguration();
  config.setCredentials(new DefaultBceCredentials(configuration.getAccessKey(), configuration.getSecretKey()));
  config.setEndpoint(configuration.getEndPoint());
  bos = new BosClient(config);
}
 
开发者ID:perrywang,项目名称:dionysus,代码行数:9,代码来源:BOSService.java


示例16: BOSService

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public BOSService(BOSServiceBuilder builder) {
  this.bucket = builder.getBucket();
  BosClientConfiguration config = new BosClientConfiguration();
  BceCredentials credential = new DefaultBceCredentials(builder.getAccessKey(),
      builder.getSecretKey());
  config.setCredentials(credential);
  config.setEndpoint(builder.getEndPoint());
  bos = new BosClient(config);
}
 
开发者ID:perrywang,项目名称:dionysus,代码行数:10,代码来源:BOSService.java


示例17: VodClient

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
/**
 * Constructs a new client using the client configuration.
 *
 * @param vodConfig The client configuration options controlling how this client connects to Vod services
 *            (e.g. proxy settings, retry counts, etc).
 */
public VodClient(BceClientConfiguration vodConfig) {
    // enable HTTP Async manner for PUT method
    super(vodConfig, responseHandlers, true);

    BosClientConfiguration bosConfig = new BosClientConfiguration(vodConfig, null).withRegion(Region.CN_N1);
    bosClient = new BosClient(bosConfig);

}
 
开发者ID:baidubce,项目名称:bce-sdk-java,代码行数:15,代码来源:VodClient.java


示例18: init

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
@PostConstruct
public void init() {
    BosClientConfiguration config = new BosClientConfiguration();
    config.setCredentials(new DefaultBceCredentials(key, secret));
    config.setEndpoint(url);
    client = new BosClient(config);
}
 
开发者ID:chocotan,项目名称:lolibox,代码行数:8,代码来源:BaiduStorageService.java


示例19: FileUploadSession

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
public FileUploadSession(BosClient bosClient) {
    this.bosClient = bosClient;
}
 
开发者ID:baidubce,项目名称:bce-sdk-java,代码行数:4,代码来源:FileUploadSession.java


示例20: bosUploadDocument

import com.baidubce.services.bos.BosClient; //导入依赖的package包/类
/**
 * publish a Document.
 *
 * @param bucketName  The bucket name response from register.
 * @param objectName  The object name response from register.
 * @param file  The Document file need to be uploaded.
 * @param endpoint  The bos endpoint response from register.
 *
 * @return A PublishDocumentResponse object containing the information returned by Document.
 */
private void bosUploadDocument(String bucketName, String objectName, File file, String endpoint) {
    BosClientConfiguration config = new BosClientConfiguration(this.config);
    config.setEndpoint(endpoint);
    BosClient bosClient = new BosClient(config);

    PutObjectResponse response = bosClient.putObject(bucketName, objectName, file);
}
 
开发者ID:baidubce,项目名称:bce-sdk-java,代码行数:18,代码来源:DocClient.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AuthMethod类代码示例发布时间:2022-05-23
下一篇:
Java IteratorChain类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap