1 开始上传视频 start_upload方法
function start_upload(cookie,filename,size);
//post 参数
var form =
{
'fsize':size,
'object':filename,
'parallel':'3',//表示多少个线程同时上传视频
'insertOnly':'1',
'channel':'bjyt'
}
url : https://v.sj.360.cn/upload/video/request
/*
* cookie:用户登录保存cookie
* filename:上传视频文件名,不含路径
* size:文件大小(Byte)
*/
2 多线程上传视频
url: 1步骤返回JSON下的next_block_url + bhash
bhash加密方法:
function sha1(data) {
function n() {
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
this.h0 = 1732584193,
this.h1 = 4023233417,
this.h2 = 2562383102,
this.h3 = 271733878,
this.h4 = 3285377520,
this.block = this.start = this.bytes = 0,
this.finalized = this.hashed = !1,
this.first = !0
}
var r = "object" == typeof e ? e: {}; ! r.JS_SHA1_NO_NODE_JS && "object" == typeof process && process.versions && process.versions.node && (r = global);
var i = (!r.JS_SHA1_NO_COMMON_JS && "object" == typeof module && module.exports, "function" == typeof t && t.amd, "0123456789abcdef".split("")),
s = [ - 2147483648, 8388608, 32768, 128],
o = [24, 16, 8, 0],
u = ["hex", "array", "digest", "arrayBuffer"],
a = [],
f = function(e) {
return function(t) {
return (new n()).update(t)[e]()
}
};
return n.prototype.update = function(e) {
if (!this.finalized) {
var t = "string" != typeof e;
t && e.constructor === r.ArrayBuffer && (e = new Uint8Array(e));
for (var n, i, s = 0,
u = e.length || 0,
a = this.blocks; s < u;) {
if (this.hashed && (this.hashed = !1, a[0] = this.block, a[16] = a[1] = a[2] = a[3] = a[4] = a[5] = a[6] = a[7] = a[8] = a[9] = a[10] = a[11] = a[12] = a[13] = a[14] = a[15] = 0), t) for (i = this.start; s < u && i < 64; ++s) a[i >> 2] |= e[s] << o[3 & i++];
else for (i = this.start; s < u && i < 64; ++s) n = e.charCodeAt(s),
n < 128 ? a[i >> 2] |= n << o[3 & i++] : n < 2048 ? (a[i >> 2] |= (192 | n >>