We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
这是我的签名函数
open class QiNBaseController { @Value("\${qiniu.ak}") private lateinit var ak: String @Value("\${qiniu.sk}") private lateinit var sk: String fun generData(method: String,path:String,raqQuery:String?,host:String,contentType:String?,bodyStr:String?):String{ var data = "$method $path" if(raqQuery!=null){ data += "?$raqQuery" } data += "\nHost: $host" if(contentType!=null){ data += "\nContent-Type: $contentType" } data += "\n\n" val bodyOk = contentType!=null && bodyStr != null val contentTypeOk = contentType!=null && contentType != "application/octet-stream" if(bodyOk && contentTypeOk){ data += bodyStr } Console.log(data) return data } //生成token fun auchCode(data: String): String{ val encodedSign = base64Encode(hmac(data)) return "Qiniu $ak:$encodedSign"; } //hmac编码 private fun hmac(value: String) : String { return HmacUtils(HmacAlgorithms.HMAC_SHA_1,sk).hmacHex(value) } //base64编码 private fun base64Encode(value: String):String{ return Base64.encode(value) }
使用
@RestController @RequestMapping("/api") class QiNController : QiNBaseController(){ @GetMapping("/qn/straeams") fun getStreams() :ResultJson<String>{ val host = "pili.qiniuapi.com" var url = "/v2/hubs/girlmerry/streams" val contentType = "application/x-www-form-urlencoded" val data = generData( method = "GET", bodyStr = null, host = host, path = url, raqQuery = null, contentType = contentType ) val authorization = auchCode(data) print(authorization) val get = HttpRequest.get("https://$host$url").header("Authorization",authorization) return ResultJson.SUCCESS(get.execute().body()) } }
可以帮忙看看签名哪里错了吗?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这是我的签名函数
使用
可以帮忙看看签名哪里错了吗?
The text was updated successfully, but these errors were encountered: