惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
Spread Privacy
Spread Privacy
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
S
Schneier on Security
B
Blog
The Register - Security
The Register - Security
SecWiki News
SecWiki News
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
T
Tenable Blog
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
D
DataBreaches.Net
S
Secure Thoughts
Security Latest
Security Latest
H
Heimdal Security Blog
The Hacker News
The Hacker News
O
OpenAI News
AWS News Blog
AWS News Blog
量子位
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
腾讯CDC
U
Unit 42
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hugging Face - Blog
Hugging Face - Blog
The Last Watchdog
The Last Watchdog
Recorded Future
Recorded Future
V2EX - 技术
V2EX - 技术
爱范儿
爱范儿
F
Full Disclosure

博客园 - 伽马科技.攻城师

管理git生成的多个ssh key Docker基础教程(命令详解) Docker基础教程(常用命令篇) Docker基础教程(安装篇) 常用的Jquery插件 自定义webkit浏览器滚动条样式 centos tar压缩与解压缩命令大全 Nginx编译安装(Centos) Nginx的启动脚本(Centos) ffmpeg 音频转换(amr2mp3) 安装php openssl扩展 centos手动编译安装apache、php、mysql 添加自编译的apache为linux系统服务 Jquery datatables 使用方法 HTML5 图片缩放功能 2015年12月中国航空公司名录 HTML5 开发框架 利用HTML5定位功能,实现在百度地图上定位 openerp7 时区问题
七牛图片上传JSSDK
伽马科技.攻城师 · 2016-04-08 · via 博客园 - 伽马科技.攻城师

BASE64图片上传

接口说明:

POST /putb64/<Fsize>/key/<EncodedKey>/mimeType/<EncodedMimeType>/crc32/<Crc32>/x:user-var/<EncodedUserVarVal>
Host: upload.qiniu.com
Authorization: UpToken <UpToken>
Content-Type: application/octet-stream

<Base64EncodedFileContent>
  • <Fsize>: 必选,文件大小,没经过base64处理的原图的字节大小,支持传入 -1 表示文件大小以 http request body 为准。

  • <EncodedKey>: 可选,如果没有指定则:如果 uptoken.SaveKey 存在则基于 SaveKey 生产 key,否则用 hash 值作 key。

  • <EncodedMimeType>:可选, 文件的 MIME 类型,默认是 application/octet-stream。

  • <Crc32>: 可选,文件内容的 crc32 校验值,不指定则不进行校验。

  • Authorization:UpToken与后面的字符串保留一个空格。后面跟上你在服务端请求的token的字符串。

举例:

function putb64(){    
  var pic = "base64后的图片字符串";
  var url = "http://up.qiniu.com/putb64/20264";
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange=function(){
    if (xhr.readyState==4){
        document.getElementById("myDiv").innerHTML=xhr.responseText; } } xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/octet-stream"); xhr.setRequestHeader("Authorization", "UpToken 从服务端获取的上传token"); xhr.send(pic); }