Giter VIP home page Giter VIP logo

galaxy-fds-sdk-java's Introduction

Galaxy FDS Java SDK User Guide

Installing

  1. Download source codes from github ,build and install the jars into local maven repository (or deploy to a central Maven repository). github link: https://github.com/XiaoMi/galaxy-fds-sdk-java.git

mvn clean package install

  1. If use Maven to management, users can download the latest jar for maven central repository.The latest version is 1.5.0.

Usage

  1. Import the above jars into the project classpath or add the following dependency if your project is managed with Maven.
    <dependency>
      	<groupId>com.xiaomi.infra.galaxy</groupId>
    		<artifactId>galaxy-fds-sdk-java</artifactId>
    		<version>3.0.41</version>
    </dependency>
  1. Add the jar to classpath.

Unit Tests(Examples)

  1. Visit https://dev.mi.com/keycenter and edit galaxy-fds-sdk-java/src/test/resources/test.properties like this: image

  2. Run galaxy-fds-sdk-java/src/test/java/com/xiaomi/infra/galaxy/fds/client/TestGalaxyFDSClient.java as unit test.

galaxy-fds-sdk-java's People

Contributors

haxiaolin avatar hujianxin avatar lshangq avatar shenjiaqi avatar zjbzju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

galaxy-fds-sdk-java's Issues

fds 下载源码getObject bug

版本号

当前最新版本号是:3.0.14
我使用的版本是:3.0.14

问题描述

GalaxyFDSClient.getObject(String bucketName, String objectName, String versionId, long pos)
该方法963行存在笔误bug
if (rtnObject == null) { closeResponseEntity(response); }

该bug在下载的时候,由于未能及时关闭连接,导致连接数超过默认的20时候,程序挂起。

解决方法

删除条件判断即可

当objects非常多时,如何 list objects或者目录

fds 没有目录概念, 而是用 "/" 模拟目录, 因此listObjects 接口可以用来list 某一前缀的objects, delimiter参数可以用于将相同prefix的objects聚合在一起, 利用delimiter, 可以达到list 某个目录下的文件夹的效果。

listObject接口默认最多返回1000个object,当bucket下object过多时,需要用到listNextBatchOfObjectslistNextBatchOfObjects的作用是根据上次结果继续list。其输入为FDSObjectListing。 Java 用例:

  • list 某一前缀所有objects
for (FDSObjectListing objectListing = fdsClient.listObjects(BUCKET_NAME, PREFIX, ""); objectListing != null;
     objectListing = fdsClient.listNextBatchOfObjects(objectListing)) {
  //do something
  // objectListing.objectSummaries() 为预期objects
  if (!objectListing.isTruncated()) {
    break;
  }
}
  • list 某一前缀下所有目录
// PREFIX 以 / 为结尾
for (FDSObjectListing objectListing = fdsClient.listObjects(BUCKET_NAME, PREFIX, "/"); objectListing != null;
     objectListing = fdsClient.listNextBatchOfObjects(objectListing)) {
  //do something
  // objectListing.getCommonPrefixes() 为预期目录
  if (!objectListing.isTruncated()) {
    break;
  }
}

如何通过预签名上传时,设置object为public?

生成预签名需要填写对应Method、SubResource、ContentType,SubResource用来控制这个url签出后所带的参数,当要用于分片上出传初始化时,填写uploads,此外如果想通过预签名上传object,同时设置object为public,填写cannedAcl=PUBLIC_READ。 以Java sdk为例:

generatePresignedUri(BUCKET_NAME, OBJECT_NAME, Arrays.asList("cannedAcl=" + CannedAcl.PUBLIC_READ.name()), new Date(System.currentTimeMillis() + 1000000), HttpMethod.PUT, "");

404 url

the url [https://github.com/XiaoMi/galaxy-fds-sdk-java.git] in page:[https://github.com/XiaoMi/galaxy-fds-sdk-java] return 404

请求403调查

签名错误

status=403, reason=[Galaxy FDS Error: Signature Does Not Match [Check http header or query parameter in request, Make sure your request is correctly signed]

  • ak 或者 sk 错误
  • objectName 不能以'/'开头
  • 文件编码问题(极少可能)
  • (仅在预签名url请求)如果在生成预签名url时,没有指定content-tyoe, 默认为空,即("content-type:"), 上传时需要显示的指定"content-type:"

status=403, reason=Galaxy FDS Error: Request Time Too Skewed [Date in your request header differs with local time in FDS too much, Check local time of client]

  • 本地时间不对
  • 并发太大(client 默认最大连接数为20, 如果超过会等待直到链接可用)

status=403, reason=Bucket Access Denied: Only owner is allowed to edit bucket property

  • 使用的aksk 对应的teamId(CI开头)未被正确赋予bucket权限

status=403, reason=Object Access Denied: Object is not allowed outside access

  • 融合云集群默认无法外网访问(通过外网域名), 可以在控制台开启bucket外网访问或者用内网域名(关闭cdn)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.