ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# ## 1、获得授权access_token 访问这个接口需要提供`appid`和`secret`,这两者需要到富源平台注册应用,然后在应用的右侧获得。 这个`access_token`的有效时间为两个小时,请注意管理避免过期。 # ~~~[api:notDebug] get:/v1/token *appid=a44r4aMbO7BZ1NoW#申请的appid *secret=a4474wRq9BwujRV7hM4SGH0QMyrEJF5J#申请的appsecret *grant_type=client_credential#类型 <<< success { "accessToken": "a447bdDAUeKORvmt", "expires": 7200 } <<< 403 { "status": 403, "error": "SecretIsInvalid", "message": "无效的 secret" } ~~~ # ## 2,上传文档 将文件以指定的key值上传,注意key不能以`/`开头: * `/abc/e.jpg`:错误 * `abc/e.jpg`:正确 # ~~~[api:base] post:http://foxconn.gateway.api.liyueyun.com/api/lss/attachments *key=myFolder/secFolder/fileName.jpg#附件的Key,支持目录格式。相同Key的文档会被覆盖 <<< success { "success": true } <<< 500 错误一 {  error:"App_Module_Not_Formal",  message:"此服务模块还未申请正式"  } 错误二 { error:"Params_key_Missing", message:"参数key不能为空!" } <<< 400 { "status": 400, "error": "FRS.0001", "message": "输入格式不正确" } <<< 401 错误一: { "status": 401, "error": "AccessTokenNoExist", "message": "必须有 accessToken" } 错误二: { "status": 401, "error": "AccessTokenIsInvalid", "message": "无效的 accessToken" } 错误三: { "status": 401, "error": "AccessTokenHasExpired", "message": "accessToken 已过期" } <<< 403 错误一: { "status": 403, "error": "SecretIsInvalid", "message": "无效的 secret" } 错误二: { "status": 403, "error": "SecretHasDisabled", "message": "secret 已被禁用" } 错误三: { "status": 403, "error": "SecretError", "message": "secret 状态异常" } 错误四: { "status": 403, "error": "LimitExceeded", "message": "已超出用量限制" } ~~~ # # ##### C#访问示例代码: ~~~CSharp var client = new RestClient("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments?key=myFolder/secFolder/fileName.jpg"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer a447bdDAUeKORvmt"); // 这里的a447bdDAUeKORvmt就是接口1取得的access_token request.AddParameter("application/octet-stream", "<file contents here>", ParameterType.RequestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ~~~ # ##### Java访问示例代码: ~~~ java OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/octet-stream"); RequestBody body = RequestBody.create(mediaType, "<file contents here>"); Request request = new Request.Builder() .url("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments?key=myFolder/secFolder/fileName.jpg") .method("POST", body) .addHeader("Authorization", "Bearer a447bdDAUeKORvmt") // 这里的a447bdDAUeKORvmt就是接口1取得的access_token .build(); Response response = client.newCall(request).execute(); ~~~ # #### Nodejs访问示例代码 ~~~javascript var unirest = require('unirest'); var req = unirest('POST', 'http://foxconn.gateway.api.liyueyun.com/api/lss/attachments?key=myFolder/secFolder/fileName.jpg') .headers({ 'Content-Type': 'application/octet-stream', 'Authorization': 'Bearer a447bdDAUeKORvmt' // 这里的a447bdDAUeKORvmt就是接口1取得的access_token }) .send("<file contents here>") .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ~~~ # # ## 3,获得文档的访问权限 可以取得文档的访问权限,如`public`,`private`或是`null`。当是`null`时表示这个文档不存在。 # ~~~[api:base] get:http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/acl *key=myFolder/secFolder/fileName.jpg#文档的Key,支持目录格式。 <<< 200 {  "accessControlList":{ "grant":"null" // 这里的值有三个:['public','private','null'] ,分别表示:公开,私有,不存在 } } <<< 500 错误一 {  error:"App_Module_Not_Formal",  message:"此服务模块还未申请正式"  } 错误二 { error:"Params_key_Missing", message:"参数key不能为空!" } <<< 400 { "status": 400, "error": "FRS.0001", "message": "输入格式不正确" } <<< 401 错误一: { "status": 401, "error": "AccessTokenNoExist", "message": "必须有 accessToken" } 错误二: { "status": 401, "error": "AccessTokenIsInvalid", "message": "无效的 accessToken" } 错误三: { "status": 401, "error": "AccessTokenHasExpired", "message": "accessToken 已过期" } <<< 403 错误一: { "status": 403, "error": "SecretIsInvalid", "message": "无效的 secret" } 错误二: { "status": 403, "error": "SecretHasDisabled", "message": "secret 已被禁用" } 错误三: { "status": 403, "error": "SecretError", "message": "secret 状态异常" } 错误四: { "status": 403, "error": "LimitExceeded", "message": "已超出用量限制" } ~~~ # # ##### C#访问示例代码: ~~~CSharp var client = new RestClient("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/acl?key=myFolder/secFolder/fileName.jpg"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer a447bdDAUeKORvmt"); // 这里的a447bdDAUeKORvmt就是接口1取得的access_token IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ~~~ # ##### Java访问示例代码: ~~~ java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/acl?key=myFolder/secFolder/fileName.jpg") .method("GET", null) .addHeader("Authorization", "Bearer a447bdDAUeKORvmt") // 这里的a447bdDAUeKORvmt就是接口1取得的access_token .build(); Response response = client.newCall(request).execute(); ~~~ # #### Nodejs访问示例代码 ~~~javascript var unirest = require('unirest'); var req = unirest('GET', 'http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/acl?key=myFolder/secFolder/fileName.jpg') .headers({ 'Authorization': 'Bearer a447bdDAUeKORvmt' // 这里的a447bdDAUeKORvmt就是接口1取得的access_token }) .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ~~~ # # ## 4,直接下载文档 获得文档的二进制流。 # ~~~[api:base] get:http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/download *key=myFolder/secFolder/fileName.jpg#文档的Key,支持目录格式。 <<< <文件二进制> <<< 500 错误一 {  error:"App_Module_Not_Formal",  message:"此服务模块还未申请正式"  } 错误二 { error:"Params_key_Missing", message:"参数key不能为空!" } <<< 400 { "status": 400, "error": "FRS.0001", "message": "输入格式不正确" } <<< 401 错误一: { "status": 401, "error": "AccessTokenNoExist", "message": "必须有 accessToken" } 错误二: { "status": 401, "error": "AccessTokenIsInvalid", "message": "无效的 accessToken" } 错误三: { "status": 401, "error": "AccessTokenHasExpired", "message": "accessToken 已过期" } <<< 403 错误一: { "status": 403, "error": "SecretIsInvalid", "message": "无效的 secret" } 错误二: { "status": 403, "error": "SecretHasDisabled", "message": "secret 已被禁用" } 错误三: { "status": 403, "error": "SecretError", "message": "secret 状态异常" } 错误四: { "status": 403, "error": "LimitExceeded", "message": "已超出用量限制" } ~~~ # # ##### C#访问示例代码: ~~~CSharp var client = new RestClient("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/download?key=myFolder/secFolder/fileName.jpg"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer a447bdDAUeKORvmt"); // 这里的a447bdDAUeKORvmt就是接口1取得的access_token IRestResponse response = client.Execute(request); ~~~ # ##### Java访问示例代码: ~~~ java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/download?key=myFolder/secFolder/fileName.jpg") .method("GET", null) .addHeader("Authorization", "Bearer a447bdDAUeKORvmt") // 这里的a447bdDAUeKORvmt就是接口1取得的access_token .build(); Response response = client.newCall(request).execute(); ~~~ # #### Nodejs访问示例代码 ~~~javascript var unirest = require('unirest'); var req = unirest('GET', 'http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/download?key=myFolder/secFolder/fileName.jpg') .headers({ 'Authorization': 'Bearer a447bdDAUeKORvmt' // 这里的a447bdDAUeKORvmt就是接口1取得的access_token }) .end(function (res) { if (res.error) throw new Error(res.error); //这里保存返回的文件流 }); ~~~ # # ## 5,取得文档的临时公开访问地址 接口可以取得文档,但这是一个私有接口,访问需要提供token,而在业务系统中常常需要提供一个临时公开的文档 # ~~~[api:base] get:http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/download *key=myFolder/secFolder/fileName.jpg#文档的Key,支持目录格式。 <<< <文件二进制> <<< 500 错误一 {  error:"App_Module_Not_Formal",  message:"此服务模块还未申请正式"  } 错误二 { error:"Params_key_Missing", message:"参数key不能为空!" } <<< 400 { "status": 400, "error": "FRS.0001", "message": "输入格式不正确" } <<< 401 错误一: { "status": 401, "error": "AccessTokenNoExist", "message": "必须有 accessToken" } 错误二: { "status": 401, "error": "AccessTokenIsInvalid", "message": "无效的 accessToken" } 错误三: { "status": 401, "error": "AccessTokenHasExpired", "message": "accessToken 已过期" } <<< 403 错误一: { "status": 403, "error": "SecretIsInvalid", "message": "无效的 secret" } 错误二: { "status": 403, "error": "SecretHasDisabled", "message": "secret 已被禁用" } 错误三: { "status": 403, "error": "SecretError", "message": "secret 状态异常" } 错误四: { "status": 403, "error": "LimitExceeded", "message": "已超出用量限制" } ~~~ # # ##### C#访问示例代码: ~~~CSharp var client = new RestClient("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/download?key=myFolder/secFolder/fileName.jpg"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer a447bdDAUeKORvmt"); // 这里的a447bdDAUeKORvmt就是接口1取得的access_token IRestResponse response = client.Execute(request); ~~~ # ##### Java访问示例代码: ~~~ java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/download?key=myFolder/secFolder/fileName.jpg") .method("GET", null) .addHeader("Authorization", "Bearer a447bdDAUeKORvmt") // 这里的a447bdDAUeKORvmt就是接口1取得的access_token .build(); Response response = client.newCall(request).execute(); ~~~ # #### Nodejs访问示例代码 ~~~javascript var unirest = require('unirest'); var req = unirest('GET', 'http://foxconn.gateway.api.liyueyun.com/api/lss/attachments/download?key=myFolder/secFolder/fileName.jpg') .headers({ 'Authorization': 'Bearer a447bdDAUeKORvmt' // 这里的a447bdDAUeKORvmt就是接口1取得的access_token }) .end(function (res) { if (res.error) throw new Error(res.error); //这里保存返回的文件流 }); ~~~ # # ## 6,删除文档 删除指定key值对应的文档 # ~~~[api:base] delete:http://foxconn.gateway.api.liyueyun.com/api/lss/attachments *key=myFolder/secFolder/fileName.jpg#文档的Key,支持目录格式。 <<< 200 {  success:true } <<< 500 错误一 {  error:"App_Module_Not_Formal",  message:"此服务模块还未申请正式"  } 错误二 { error:"Params_key_Missing", message:"参数key不能为空!" } <<< 400 { "status": 400, "error": "FRS.0001", "message": "输入格式不正确" } <<< 401 错误一: { "status": 401, "error": "AccessTokenNoExist", "message": "必须有 accessToken" } 错误二: { "status": 401, "error": "AccessTokenIsInvalid", "message": "无效的 accessToken" } 错误三: { "status": 401, "error": "AccessTokenHasExpired", "message": "accessToken 已过期" } <<< 403 错误一: { "status": 403, "error": "SecretIsInvalid", "message": "无效的 secret" } 错误二: { "status": 403, "error": "SecretHasDisabled", "message": "secret 已被禁用" } 错误三: { "status": 403, "error": "SecretError", "message": "secret 状态异常" } 错误四: { "status": 403, "error": "LimitExceeded", "message": "已超出用量限制" } ~~~ # # ##### C#访问示例代码: ~~~CSharp var client = new RestClient("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments?key=myFolder/secFolder/fileName.jpg"); client.Timeout = -1; var request = new RestRequest(Method.DELETE); request.AddHeader("Authorization", "Bearer a447bdDAUeKORvmt"); // 这里的a447bdDAUeKORvmt就是接口1取得的access_token IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ~~~ # ##### Java访问示例代码: ~~~ java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("http://foxconn.gateway.api.liyueyun.com/api/lss/attachments?key=myFolder/secFolder/fileName.jpg") .method("DELETE", null) .addHeader("Authorization", "Bearer a447bdDAUeKORvmt") // 这里的a447bdDAUeKORvmt就是接口1取得的access_token .build(); Response response = client.newCall(request).execute(); ~~~ # #### Nodejs访问示例代码 ~~~javascript var unirest = require('unirest'); var req = unirest('DELETE', 'http://foxconn.gateway.api.liyueyun.com/api/lss/attachments?key=myFolder/secFolder/fileName.jpg') .headers({ 'Authorization': 'Bearer a447bdDAUeKORvmt' // 这里的a447bdDAUeKORvmt就是接口1取得的access_token }) .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ~~~