Code Monkey home page Code Monkey logo

volc-sdk-java's Introduction

火山引擎SDK for Java

欢迎使用火山引擎SDK for Java,本文档为您介绍如何获取及调用SDK。

前置准备

服务开通

请确保您已开通了您需要访问的服务。您可前往火山引擎控制台,在左侧菜单中选择或在顶部搜索栏中搜索您需要使用的服务,进入服务控制台内完成开通流程。

获取安全凭证

Access Key(访问密钥)是访问火山引擎服务的安全凭证,包含Access Key ID(简称为AK)和Secret Access Key(简称为SK)两部分。您可登录火山引擎控制台,前往“访问控制”的“访问密钥”中创建及管理您的Access Key。更多信息可参考访问密钥帮助文档

获取与安装

推荐通过Maven依赖使用火山引擎SDK for Java

maven

<dependency>
    <groupId>com.volcengine</groupId>
    <artifactId>volc-sdk-java</artifactId>
    <version>最新版本</version>
</dependency>

如果 SDK版本 高于或者等于 Java 9 请依赖javax.annotation-api 由于在高于或者等于 Java 9 中 javax.annotation-api 被移除

请在使用中引用

<dependency>
  <groupId>javax.annotation</groupId>
  <artifactId>javax.annotation-api</artifactId>
  <version>1.3.2</version>
</dependency>

SNAPSHOT发布说明

版本号:2.0.1-SNAPSHOT

注意:SNAPSHOT版本可能存在潜在问题,源码分支为2.0.0-SNAPSHOT,如您有沟通需求,请提交工单选择对应产品获得沟通

变更说明

  1. 使用OkHttp作为底层数据交互的http组件库,可以兼容安卓手机端
  2. 解决大量凭证潜在的线程泄露问题
  3. 抽象部分与网络库相关的model,避免冲突
  4. 业务包基本不感知底层变更,理论上可以平滑迁移

如何使用SNAPSHOT版本

  1. 添加SNAPSHOT的Maven仓库,SNAPSHOT策略配置请自行查阅文档
 <repository>
    <id>snapshots-repo</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
  1. 添加依赖
<dependency>
    <groupId>com.volcengine</groupId>
    <artifactId>volc-sdk-java</artifactId>
    <version>2.0.1-SNAPSHOT</version>
</dependency>

相关配置

安全凭证配置

火山引擎SDK for Java支持以下几种方式进行凭证管理:

注意:代码中Your AK及Your SK需要分别替换为您的AK及SK。

方式一:在Client中显式指定AK/SK (推荐)

iamService.setAccessKey("Your AK");
iamService.setSecretKey("Your SK");

方式二:从环境变量加载AK/SK

VOLC_ACCESSKEY="Your AK"  
VOLC_SECRETKEY="Your SK"

方式三:从HOME文件加载AK/SK

在本地的~/.volc/config中添加如下内容:

  {
    "ak": "Your AK",
    "sk": "Your SK"
  }

释放资源

当您调用完成后,通过显式的调用destroy来释放守护线程

iamService.destroy()

##其它资源 示例参见example

volc-sdk-java's People

Contributors

dcalsky avatar erentang avatar guozhifeng-felton avatar huangxing-hx avatar kartorias avatar krait8063 avatar lianhongrui avatar liuweiwei-xyz avatar lz1998 avatar ppgwobyte avatar xinghui-wu avatar yinxing0818 avatar

Stargazers

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

Watchers

 avatar  avatar

volc-sdk-java's Issues

图片格式不支持

image

请问下我在网页转的图片转base64,网页上面正常转换,但是代码报错格式不支持,是有啥问题么

部分手机上apache报错

部分手机上apache报错,官方是不是要改用encodeHex呢

 java.lang.NoSuchMethodError: No static method encodeHexString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of 'org.apache.commons.codec.binary.Hex' appears in /system/framework/org.apache.http.legacy.boot.jar)
        at com.volcengine.helper.Utils.hashSHA256(Utils.java:45)
        at com.volcengine.auth.impl.SignerV4Impl.getSignRequest(SignerV4Impl.java:100)
        at com.volcengine.http.VolcengineInterceptor.intercept(VolcengineInterceptor.java:44)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at com.volcengine.service.BaseServiceImpl.makeRequest(BaseServiceImpl.java:274)
        at com.volcengine.service.BaseServiceImpl.post(BaseServiceImpl.java:261)
        at com.volcengine.service.visual.impl.VisualServiceImpl.poemMaterial(VisualServiceImpl.java:97)
        at com.desaysv.myapplication3.TestActivity.initClient(TestActivity.java:38)
        at com.desaysv.myapplication3.TestActivity.access$000(TestActivity.java:21)
        at com.desaysv.myapplication3.TestActivity$1.run(TestActivity.java:70)

大量等待线程被创建导致服务宕机

我确实没有细看readme,但是麻烦写sdk调用示例的同学在最后一行加上translateService.destroy();销毁行吗?
volc-sdk-java/blob/main/example/src/main/java/com/volcengine/example/translate/TranslateDemo.java

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.