Skip to content

Commit

Permalink
+ 189cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
reruin committed Mar 2, 2020
1 parent a780973 commit 68c2a80
Show file tree
Hide file tree
Showing 6 changed files with 805 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/plugins/drive.http.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = ({wrapReadableStream , request}) => {

const getFileSize = async (url , headers) => {
try{
let nh = await request.header(url , {headers})
let nh = await request.header(decodeURIComponent(url) , {headers})
if(nh && nh['content-length']){
return nh['content-length']
}else{
Expand All @@ -40,7 +40,7 @@ module.exports = ({wrapReadableStream , request}) => {
let url = encodeURI(`http:${id}`)
let size = await getFileSize(url)
console.log('get file size' , size)
let readstream = request({url, method:'get'})
let readstream = request({url:decodeURIComponent(url), method:'get'})
return wrapReadableStream(readstream , { size } )
}

Expand Down
4 changes: 2 additions & 2 deletions app/plugins/drive.https.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = ({wrapReadableStream , request}) => {

const getFileSize = async (url , headers) => {
try{
let nh = await request.header(url , {headers})
let nh = await request.header(decodeURIComponent(url) , {headers})
if(nh && nh['content-length']){
return nh['content-length']
}else{
Expand All @@ -40,7 +40,7 @@ module.exports = ({wrapReadableStream , request}) => {
let url = encodeURI(`https:${id}`)
let size = await getFileSize(url)
console.log('get file size' , size)
let readstream = request({url, method:'get'})
let readstream = request({url:decodeURIComponent(url), method:'get'})
return wrapReadableStream(readstream , { size } )
}

Expand Down
2 changes: 1 addition & 1 deletion app/utils/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const http = (opts, ...rest) => {
if (opts.async) {
return new Promise(function(resolve, reject) {
request(opts, function(error, response, body) {
if (!error && response.statusCode == 200) {
if (!error) {
resolve(response)
} else {
reject(error || response);
Expand Down
2 changes: 1 addition & 1 deletion app/utils/wrapReadableStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class wrapReadableStream extends Readable {
response.on('data' , (chunk)=>{
let bytesRead = chunk.length
this.length += bytesRead

console.log( this.length )
if(bytesRead > 0){
this.buffers.push(chunk.slice(0));
if(this.needReadable){
Expand Down
Binary file not shown.
Loading

0 comments on commit 68c2a80

Please sign in to comment.