Android SDK

<p class="shortdesc"></p> <section class="section" id="Android_SDK___section_p4z_s5m_qlb"><h2 class="doc-tairway">1. 简介</h2> <ul class="ul" id="Android_SDK___ul_ltq_v5m_qlb"> <li class="li">本文档主要介绍 OBS Android SDK 的接口使用及注意事项;</li> <li class="li">并且假设您已经开通了 OBS 服务,并已是平安公有云用户;</li> <li class="li">如果您还没有开通或者还不了解平安云 OBS 服务,请登录 <a class="xref" href="/ssr/products/OBS" target="_blank">OBS产品主页</a>进行了解;</li> <li class="li">OBS-Android-SDK 是由平安云团队开发的工具包。便于开发者在 Android 上方便使用平安云当中的 OBS 服务;</li> <li class="li">文档主要罗列了 OBS-Android-SDK 中,上传以及下载的一些基本方法,并对方法参数进行简要解释,且对响应方法有一个详细的说明。</li> </ul> </section> <section class="section" id="Android_SDK___section_dwc_t5m_qlb"><h2 class="doc-tairway">2. SDK下载</h2> <p class="p">Android SDK 开发包最新版本 <a class="xref" href="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/sdk%2Fobs-android-sdk-1.2.0.jar?response-content-disposition=attachment%3Bfilename%3Dobs-android-sdk-1.2.0.jar" target="_blank">v1.2.0</a></p> </section> <section class="section" id="Android_SDK___section_lvd_t5m_qlb"><h2 class="doc-tairway">3. API概览</h2> <table class="table" id="Android_SDK___table_n4f_z5m_qlb"><caption></caption><colgroup><col style="width:35.97122302158273%"><col style="width:64.02877697841726%"></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="Android_SDK___table_n4f_z5m_qlb__entry__1"><p class="p">API</p></th> <th class="entry" id="Android_SDK___table_n4f_z5m_qlb__entry__2"><p class="p">描述</p></th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__1 "><p class="p">init</p></td> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__2 "><p class="p">初始化服务</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__1 "><p class="p">uploadFile</p></td> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__2 "> <p class="p">上传文件</p> <p class="p">OBS SDK提供了丰富的文件上传接口,可以通过以下方式上传文件:</p> <ul class="ul" id="Android_SDK___ul_o4f_z5m_qlb"> <li class="li">文件上传</li> <li class="li">分片上传</li> </ul> </td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__1 "><p class="p">sliceUploadFile</p></td> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__2 "><p class="p">分片上传文件</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__1 "><p class="p">uploadImageScale</p></td> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__2 "><p class="p">压缩上传图片</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__1 "><p class="p">downloadFile</p></td> <td class="entry" headers="Android_SDK___table_n4f_z5m_qlb__entry__2 "><p class="p">下载文件</p></td> </tr> </tbody></table> </section> <section class="section" id="Android_SDK___section_jh2_t5m_qlb"><h2 class="doc-tairway">4. API描述</h2> <p class="p"><strong class="ph b">(1) init</strong></p> <p class="p"><strong class="ph b">接口描述</strong></p> <p class="p">初始化服务,在 Application 中初始化:</p> <pre class="pre codeblock"><code>RequestManager.getInstance().init(this); </code></pre> <p class="p"><strong class="ph b">(2) uploadFile</strong></p> <p class="p"><strong class="ph b">接口描述</strong></p> <p class="p">根据文件路径上传</p> <p class="p"><strong class="ph b">请求参数</strong></p> <table class="table" id="Android_SDK___table_sf5_gvm_qlb"><caption></caption><colgroup><col><col><col><col><col></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="Android_SDK___table_sf5_gvm_qlb__entry__1"><p class="p">参数名称</p></th> <th class="entry" id="Android_SDK___table_sf5_gvm_qlb__entry__2"><p class="p">参数类型</p></th> <th class="entry" id="Android_SDK___table_sf5_gvm_qlb__entry__3"><p class="p">是否必须</p></th> <th class="entry" id="Android_SDK___table_sf5_gvm_qlb__entry__4"><p class="p">参数描述</p></th> <th class="entry" id="Android_SDK___table_sf5_gvm_qlb__entry__5"><p class="p">备注</p></th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__1 "><p class="p">bucket</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__4 "><p class="p">所要上传到指定bucket的名称</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__1 "><p class="p">fileKey</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__4 "><p class="p">对应bucket里文件的key</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__1 "><p class="p">filePath</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__4 "><p class="p">上传文件路径</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__1 "><p class="p">config</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__2 "><p class="p">Configuration </p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__4 "><p class="p">配置上传下载服务器地址</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__1 "><p class="p">requestListener </p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__2 "><p class="p">RequestListener</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__4 "><p class="p">请求的回调</p></td> <td class="entry" headers="Android_SDK___table_sf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> </tbody></table> <p class="p"><strong class="ph b">响应参数</strong></p> <p class="p">无</p> <p class="p"><strong class="ph b">(3) uploadFile</strong></p> <p class="p"><strong class="ph b">接口描述</strong></p> <p class="p">根据文件上传</p> <p class="p"><strong class="ph b">请求参数</strong></p> <table class="table" id="Android_SDK___table_uf5_gvm_qlb"><caption></caption><colgroup><col><col><col><col><col></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="Android_SDK___table_uf5_gvm_qlb__entry__1"><p class="p">参数名称</p></th> <th class="entry" id="Android_SDK___table_uf5_gvm_qlb__entry__2"><p class="p">参数类型</p></th> <th class="entry" id="Android_SDK___table_uf5_gvm_qlb__entry__3"><p class="p">是否必须</p></th> <th class="entry" id="Android_SDK___table_uf5_gvm_qlb__entry__4"><p class="p">参数描述</p></th> <th class="entry" id="Android_SDK___table_uf5_gvm_qlb__entry__5"><p class="p">备注</p></th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__1 "><p class="p">bucket</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__4 "><p class="p">所要上传到指定bucket的名称</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__1 "><p class="p">fileKey</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__4 "><p class="p">对应bucket里文件的key</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__1 "><p class="p">file</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__2 "><p class="p">File</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__4 "><p class="p">上传文件对象</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__1 "><p class="p">config</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__2 "><p class="p">Configuration </p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__4 "><p class="p">配置上传下载服务器地址</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__1 "><p class="p">requestListener </p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__2 "><p class="p">RequestListener</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__4 "><p class="p">请求的回调</p></td> <td class="entry" headers="Android_SDK___table_uf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> </tbody></table> <p class="p"><strong class="ph b">响应参数</strong></p> <p class="p">无</p> <p class="p"><strong class="ph b">(4) sliceUploadFile</strong></p> <p class="p"><strong class="ph b">接口描述</strong></p> <p class="p">分片上传文件</p> <p class="p"><strong class="ph b">请求参数</strong></p> <table class="table" id="Android_SDK___table_wf5_gvm_qlb"><caption></caption><colgroup><col><col><col><col><col></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="Android_SDK___table_wf5_gvm_qlb__entry__1"><p class="p">参数名称</p></th> <th class="entry" id="Android_SDK___table_wf5_gvm_qlb__entry__2"><p class="p">参数类型</p></th> <th class="entry" id="Android_SDK___table_wf5_gvm_qlb__entry__3"><p class="p">是否必须</p></th> <th class="entry" id="Android_SDK___table_wf5_gvm_qlb__entry__4"><p class="p">参数描述</p></th> <th class="entry" id="Android_SDK___table_wf5_gvm_qlb__entry__5"><p class="p">备注</p></th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__1 "><p class="p">bucket</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__4 "><p class="p">所要上传到指定bucket的名称</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__1 "><p class="p">fileKey</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__4 "><p class="p">对应bucket里文件的key</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__1 "><p class="p">filePath</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__4 "><p class="p">上传文件路径</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__1 "><p class="p">config</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__2 "><p class="p">Configuration </p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__4 "><p class="p">配置上传下载服务器地址</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__5 "><p class="p">必须设置recorder参数</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__1 "><p class="p">requestListener </p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__2 "><p class="p">RequestListener</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__4 "><p class="p">请求的回调</p></td> <td class="entry" headers="Android_SDK___table_wf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> </tbody></table> <p class="p"><strong class="ph b">响应参数</strong></p> <p class="p">无</p> <p class="p"><strong class="ph b">(5) uploadImageScale</strong></p> <p class="p"><strong class="ph b">接口描述</strong></p> <p class="p">压缩上传图片</p> <p class="p"><strong class="ph b">请求参数</strong></p> <table class="table" id="Android_SDK___table_yf5_gvm_qlb"><caption></caption><colgroup><col><col><col><col><col></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="Android_SDK___table_yf5_gvm_qlb__entry__1"><p class="p">参数名称</p></th> <th class="entry" id="Android_SDK___table_yf5_gvm_qlb__entry__2"><p class="p">参数类型</p></th> <th class="entry" id="Android_SDK___table_yf5_gvm_qlb__entry__3"><p class="p">是否必须</p></th> <th class="entry" id="Android_SDK___table_yf5_gvm_qlb__entry__4"><p class="p">参数描述</p></th> <th class="entry" id="Android_SDK___table_yf5_gvm_qlb__entry__5"><p class="p">备注</p></th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__1 "><p class="p">bucket</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__4 "><p class="p">所要上传到指定bucket的名称</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__1 "><p class="p">fileKey</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__2 "><p class="p">String</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__4 "><p class="p">对应bucket里文件的key</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__1 "><p class="p">file</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__2 "><p class="p">File</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__4 "><p class="p">上传文件路径</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__1 "><p class="p">config</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__2 "><p class="p">Configuration </p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__4 "><p class="p">配置上传下载服务器地址</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__5 "><p class="p">必须设置recorder参数 </p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__1 "><p class="p">compress</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__2 "><p class="p">float</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__4 "><p class="p">缩小的比例0-1</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__1 "><p class="p">requestListener </p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__2 "><p class="p">RequestListener</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__3 "><p class="p">true</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__4 "><p class="p">请求的回调</p></td> <td class="entry" headers="Android_SDK___table_yf5_gvm_qlb__entry__5 "><p class="p">-</p></td> </tr> </tbody></table> <p class="p"><strong class="ph b">响应参数</strong></p> <p class="p">无</p> <p class="p"><strong class="ph b">(6)downloadFile</strong></p> <p class="p"><strong class="ph b">接口描述</strong></p> <p class="p">下载文件</p> <p class="p"><strong class="ph b">请求参数</strong></p> <table class="table" id="Android_SDK___table_c3x_pdv_slb"><caption></caption><colgroup><col><col><col><col><col></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="Android_SDK___table_c3x_pdv_slb__entry__1">参数名称</th> <th class="entry" id="Android_SDK___table_c3x_pdv_slb__entry__2">参数类型</th> <th class="entry" id="Android_SDK___table_c3x_pdv_slb__entry__3">是否必须</th> <th class="entry" id="Android_SDK___table_c3x_pdv_slb__entry__4">参数描述</th> <th class="entry" id="Android_SDK___table_c3x_pdv_slb__entry__5">备注</th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__1 "> <p class="p">bucket</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__2 "> <p class="p">String</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__3 "> <p class="p">true</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__4 "> <p class="p">所要上传到指定bucket的名称</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__5 "> <p class="p">-</p> </td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__1 "> <p class="p">fileKey</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__2 "> <p class="p">String</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__3 "> <p class="p">true</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__4 "> <p class="p">对应bucket里文件的key</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__5 "> <p class="p">-</p> </td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__1 "> <p class="p">downloadLocaPath</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__2 "> <p class="p">String</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__3 "> <p class="p">true</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__4 "> <p class="p">下载到本地的文件夹路径</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__5 "> <p class="p"> 以/结尾</p> </td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__1 "> <p class="p">config</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__2 "> <p class="p">Configuration</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__3 "> <p class="p">true</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__4 "> <p class="p">配置上传下载服务器地址</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__5 "> <p class="p">-</p> </td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__1 "> <p class="p">fileName</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__2 "> <p class="p">String</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__3 "> <p class="p">true</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__4 "> <p class="p">下载后展示的文件名</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__5 "> <p class="p">-</p> </td> </tr> <tr class="row"> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__1 "> <p class="p">requestListener </p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__2 "> <p class="p">RequestListener</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__3 "> <p class="p">true</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__4 "> <p class="p">请求的回调</p> </td> <td class="entry" headers="Android_SDK___table_c3x_pdv_slb__entry__5 "> <p class="p">-</p> </td> </tr> </tbody></table> <p class="p"><strong class="ph b">响应参数</strong></p> <table class="table" id="Android_SDK___table_d3x_pdv_slb"><caption></caption><colgroup><col><col><col><col></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="Android_SDK___table_d3x_pdv_slb__entry__1">参数名称</th> <th class="entry" id="Android_SDK___table_d3x_pdv_slb__entry__2">参数类型</th> <th class="entry" id="Android_SDK___table_d3x_pdv_slb__entry__3">参数描述</th> <th class="entry" id="Android_SDK___table_d3x_pdv_slb__entry__4">备注</th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="Android_SDK___table_d3x_pdv_slb__entry__1 "> <p class="p">/</p> </td> <td class="entry" headers="Android_SDK___table_d3x_pdv_slb__entry__2 "> <p class="p">String</p> </td> <td class="entry" headers="Android_SDK___table_d3x_pdv_slb__entry__3 "> <p class="p">sdk请求Id</p> </td> <td class="entry" headers="Android_SDK___table_d3x_pdv_slb__entry__4 "> <p class="p">可作为取消cancel下载的入参</p> </td> </tr> </tbody></table> </section> <section class="section" id="Android_SDK___section_fkv_zwn_vlb"><h2 class="doc-tairway">5.其他说明</h2> <p class="p"><strong class="ph b">(1)设置https</strong></p> <pre xmlns:version="java:net.sf.saxon.Version" class="pre codeblock language-java">Configuration config = <strong class="hl-keyword" style="color:#7f0055">new</strong> Configuration.Builder().***.useHttps(true).***.build();</pre> <p class="p"><strong class="ph b">(2)取消请求</strong></p> <pre xmlns:version="java:net.sf.saxon.Version" class="pre codeblock language-java">RequestManager.getInstance().cancel(NET_TAG);</pre> <div class="note note note_note"><span class="note__title">说明:</span> 每一个请求会返回一个唯一的tag。</div> <p class="p"><strong class="ph b">(3)签名回调</strong></p> <pre xmlns:version="java:net.sf.saxon.Version" class="pre codeblock language-java">config.setSignerCredentialProvider(<strong class="hl-keyword" style="color:#7f0055">new</strong> SignerCredentialProvider() { <em><span class="hl-annotation" style="color: gray">@Override</span></em> <strong class="hl-keyword" style="color:#7f0055">public</strong> String signContent(String content) { <em class="hl-comment" style="color:#006400">//signContent中的content的数据是由“\n”分割的参数:</em> String[] params = content.split(“\n”); <em class="hl-comment" style="color:#006400">//访问后端签名服务(建议采用POST提交,所有参数都放在Body,避免对部分参数进行url编码),返回完整的authorization(AWS AK:token),如:AWS NEM3NEE************jA2NTE3M0I0RjY:Zy3ewmKyDQyQoQLc+ssoxoPKqaE=</em> <strong class="hl-keyword" style="color:#7f0055">return</strong> authorization; } </pre> <p class="p">入参content各元素含义:</p> <ul class="ul" id="Android_SDK___ul_qhn_1xn_vlb"> <li class="li">params[0]; POST/GET……,Http method</li> <li class="li">params[1]; Bucket,桶名称</li> <li class="li">params[2]; key,文件在OBS唯一标识</li> <li class="li">params[3]; content-type,文件类型</li> <li class="li"> params[4]; date,请求产生时间(GMT格式,如:Fri, 15 May 2020 06:20:34 GMT)</li> <li class="li">params[5]; uri,一般为/{bucket}/{key}(普通上传、下载等接口uri)或者/mkblk/{bucket}/{key:.*}/{blockIndex}(分片上传接口,分片上传另外还有bput、mkfile等接口)</li> </ul> <p class="p"><strong class="ph b">后端签名服务实现</strong></p> <p class="p">(1) JAVA SDK方式</p> <p class="p">请参见<a class="xref" href="/ssr/help/storage/obs/OBS_SDK_.creatsign" target="_blank">生成签名</a>。</p> <p class="p">(2)自行实现签名算法</p> <p class="p">请参见<a class="xref" href="/ssr/help/storage/obs/api.Introduction" target="_blank">签名生成规则</a>。</p> </section>
以上内容是否解决了您的问题?
请补全提交信息!
咨询·建议

电话咨询

400-151-8800

邮件咨询

cloud@pingan.com

在线客服

工单支持

解决云产品相关技术问题