Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tiny-image
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
tiny-image
Commits
e1843170
Commit
e1843170
authored
Feb 15, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
url改为线上环境
parent
d4b70e45
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
3 deletions
+3
-3
index.js
dist/index.js
+1
-1
index.js.map
dist/index.js.map
+1
-1
index.js
src/index.js
+1
-1
No files found.
dist/index.js
View file @
e1843170
...
@@ -11,7 +11,7 @@ require('fs');
...
@@ -11,7 +11,7 @@ require('fs');
* Created by rockyl on 2020-02-13.
* Created by rockyl on 2020-02-13.
*/
*/
const
tinifyUrl
=
'http://
localhost:8090
/tinify'
;
const
tinifyUrl
=
'http://
tinify.duiba.com.cn
/tinify'
;
async
function
compressBuffer
(
buffer
)
{
async
function
compressBuffer
(
buffer
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
dist/index.js.map
View file @
e1843170
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2020-02-13.
\n
*/
\n\n
import FormData from 'form-data';
\n
import fs from 'fs';
\n\n
const tinifyUrl = 'http://localhost:8090/tinify';
\n\n
export async function compressBuffer(buffer) {\n
\t
return new Promise((resolve, reject) => {\n
\t\t
if (buffer && buffer.length > 0) {\n
\t\t\t
let form = new FormData();
\n\t\t\t
form.append('file', buffer, {\n
\t\t\t\t
filename: 'image.png',
\n\t\t\t\t
contentType: 'image/png',
\n\t\t\t
});
\n\n\t\t\t
form.submit(tinifyUrl, function (err, res) {\n
\t\t\t\t
if (err)
{
\n\t\t\t\t\treject(err);\n\t\t\t\t
}
else {\n
\t\t\t\t\t
res.resume();
\n\t\t\t\t\t
let resBuffer = Buffer.alloc(0);
\n\t\t\t\t\t
res.on('data', (d) => {\n
\t\t\t\t\t\t
resBuffer = Buffer.concat([resBuffer, d], resBuffer.length + d.length);
\n\t\t\t\t\t
});
\n\t\t\t\t\t
res.on('end', () => {\n
\t\t\t\t\t\t
if (resBuffer.length > 50)
{
\n\t\t\t\t\t\t\tresolve(resBuffer);\n\t\t\t\t\t\t
}
else {\n
\t\t\t\t\t\t\t
let str = resBuffer.toString();
\n\t\t\t\t\t\t\t
let json = JSON.parse(str);
\n\t\t\t\t\t\t\t
reject(json.msg);
\n\t\t\t\t\t\t
}
\n\t\t\t\t\t
});
\n\t\t\t\t\t
res.on('abort', () =>
{
\n\t\t\t\t\t\treject('abort')\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t
}
else {\n
\t\t\t
reject('empty buffer')
\n\t\t
}
\n\t
})
\n
}
\n
"
],
"names"
:
[],
"mappings"
:
";;;;;;;;;AAAA;;;AAGA,AAGA;AACA,MAAM,SAAS,GAAG,8BAA8B,CAAC;;AAEjD,AAAO,eAAe,cAAc,CAAC,MAAM,EAAE;CAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;EACvC,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;GAChC,IAAI,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;GAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE;IAC3B,QAAQ,EAAE,WAAW;IACrB,WAAW,EAAE,WAAW;IACxB,CAAC,CAAC;;GAEH,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE;IAC1C,IAAI,GAAG,EAAE;KACR,MAAM,CAAC,GAAG,CAAC,CAAC;KACZ,MAAM;KACN,GAAG,CAAC,MAAM,EAAE,CAAC;KACb,IAAI,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAChC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK;MACrB,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;MACvE,CAAC,CAAC;KACH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM;MACnB,IAAI,SAAS,CAAC,MAAM,GAAG,EAAE,EAAE;OAC1B,OAAO,CAAC,SAAS,CAAC,CAAC;OACnB,MAAM;OACN,IAAI,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;OAC/B,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;OAC3B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;OACjB;MACD,CAAC,CAAC;KACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM;MACrB,MAAM,CAAC,OAAO,EAAC;MACf,CAAC,CAAC;KACH;IACD,CAAC,CAAC;GACH,MAAM;GACN,MAAM,CAAC,cAAc,EAAC;GACtB;EACD,CAAC;CACF;;;;"
}
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2020-02-13.
\n
*/
\n\n
import FormData from 'form-data';
\n
import fs from 'fs';
\n\n
const tinifyUrl = 'http://tinify.duiba.com.cn/tinify';
\n\n
export async function compressBuffer(buffer) {\n
\t
return new Promise((resolve, reject) => {\n
\t\t
if (buffer && buffer.length > 0) {\n
\t\t\t
let form = new FormData();
\n\t\t\t
form.append('file', buffer, {\n
\t\t\t\t
filename: 'image.png',
\n\t\t\t\t
contentType: 'image/png',
\n\t\t\t
});
\n\n\t\t\t
form.submit(tinifyUrl, function (err, res) {\n
\t\t\t\t
if (err)
{
\n\t\t\t\t\treject(err);\n\t\t\t\t
}
else {\n
\t\t\t\t\t
res.resume();
\n\t\t\t\t\t
let resBuffer = Buffer.alloc(0);
\n\t\t\t\t\t
res.on('data', (d) => {\n
\t\t\t\t\t\t
resBuffer = Buffer.concat([resBuffer, d], resBuffer.length + d.length);
\n\t\t\t\t\t
});
\n\t\t\t\t\t
res.on('end', () => {\n
\t\t\t\t\t\t
if (resBuffer.length > 50)
{
\n\t\t\t\t\t\t\tresolve(resBuffer);\n\t\t\t\t\t\t
}
else {\n
\t\t\t\t\t\t\t
let str = resBuffer.toString();
\n\t\t\t\t\t\t\t
let json = JSON.parse(str);
\n\t\t\t\t\t\t\t
reject(json.msg);
\n\t\t\t\t\t\t
}
\n\t\t\t\t\t
});
\n\t\t\t\t\t
res.on('abort', () =>
{
\n\t\t\t\t\t\treject('abort')\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t
}
else {\n
\t\t\t
reject('empty buffer')
\n\t\t
}
\n\t
})
\n
}
\n
"
],
"names"
:
[],
"mappings"
:
";;;;;;;;;AAAA;;;AAGA,AAGA;AACA,MAAM,SAAS,GAAG,mCAAmC,CAAC;;AAEtD,AAAO,eAAe,cAAc,CAAC,MAAM,EAAE;CAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;EACvC,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;GAChC,IAAI,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;GAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE;IAC3B,QAAQ,EAAE,WAAW;IACrB,WAAW,EAAE,WAAW;IACxB,CAAC,CAAC;;GAEH,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE;IAC1C,IAAI,GAAG,EAAE;KACR,MAAM,CAAC,GAAG,CAAC,CAAC;KACZ,MAAM;KACN,GAAG,CAAC,MAAM,EAAE,CAAC;KACb,IAAI,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAChC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK;MACrB,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;MACvE,CAAC,CAAC;KACH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM;MACnB,IAAI,SAAS,CAAC,MAAM,GAAG,EAAE,EAAE;OAC1B,OAAO,CAAC,SAAS,CAAC,CAAC;OACnB,MAAM;OACN,IAAI,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;OAC/B,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;OAC3B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;OACjB;MACD,CAAC,CAAC;KACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM;MACrB,MAAM,CAAC,OAAO,EAAC;MACf,CAAC,CAAC;KACH;IACD,CAAC,CAAC;GACH,MAAM;GACN,MAAM,CAAC,cAAc,EAAC;GACtB;EACD,CAAC;CACF;;;;"
}
\ No newline at end of file
\ No newline at end of file
src/index.js
View file @
e1843170
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
import
FormData
from
'form-data'
;
import
FormData
from
'form-data'
;
import
fs
from
'fs'
;
import
fs
from
'fs'
;
const
tinifyUrl
=
'http://
localhost:8090
/tinify'
;
const
tinifyUrl
=
'http://
tinify.duiba.com.cn
/tinify'
;
export
async
function
compressBuffer
(
buffer
)
{
export
async
function
compressBuffer
(
buffer
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment