Commit e1843170 authored by rockyl's avatar rockyl

url改为线上环境

parent d4b70e45
...@@ -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) => {
......
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2020-02-13.\n */\n\nimport FormData from 'form-data';\nimport fs from 'fs';\n\nconst tinifyUrl = 'http://localhost:8090/tinify';\n\nexport async function compressBuffer(buffer) {\n\treturn new Promise((resolve, reject) => {\n\t\tif (buffer && buffer.length > 0) {\n\t\t\tlet form = new FormData();\n\t\t\tform.append('file', buffer, {\n\t\t\t\tfilename: 'image.png',\n\t\t\t\tcontentType: 'image/png',\n\t\t\t});\n\n\t\t\tform.submit(tinifyUrl, function (err, res) {\n\t\t\t\tif (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t} else {\n\t\t\t\t\tres.resume();\n\t\t\t\t\tlet resBuffer = Buffer.alloc(0);\n\t\t\t\t\tres.on('data', (d) => {\n\t\t\t\t\t\tresBuffer = Buffer.concat([resBuffer, d], resBuffer.length + d.length);\n\t\t\t\t\t});\n\t\t\t\t\tres.on('end', () => {\n\t\t\t\t\t\tif (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\tlet str = resBuffer.toString();\n\t\t\t\t\t\t\tlet json = JSON.parse(str);\n\t\t\t\t\t\t\treject(json.msg);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tres.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\treject('empty buffer')\n\t\t}\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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\nimport FormData from 'form-data';\nimport fs from 'fs';\n\nconst tinifyUrl = 'http://tinify.duiba.com.cn/tinify';\n\nexport async function compressBuffer(buffer) {\n\treturn new Promise((resolve, reject) => {\n\t\tif (buffer && buffer.length > 0) {\n\t\t\tlet form = new FormData();\n\t\t\tform.append('file', buffer, {\n\t\t\t\tfilename: 'image.png',\n\t\t\t\tcontentType: 'image/png',\n\t\t\t});\n\n\t\t\tform.submit(tinifyUrl, function (err, res) {\n\t\t\t\tif (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t} else {\n\t\t\t\t\tres.resume();\n\t\t\t\t\tlet resBuffer = Buffer.alloc(0);\n\t\t\t\t\tres.on('data', (d) => {\n\t\t\t\t\t\tresBuffer = Buffer.concat([resBuffer, d], resBuffer.length + d.length);\n\t\t\t\t\t});\n\t\t\t\t\tres.on('end', () => {\n\t\t\t\t\t\tif (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\tlet str = resBuffer.toString();\n\t\t\t\t\t\t\tlet json = JSON.parse(str);\n\t\t\t\t\t\t\treject(json.msg);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tres.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\treject('empty buffer')\n\t\t}\n\t})\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;AAGA,AAGA;AACA,MAAM,SAAS,GAAG,mCAAmC,CAAC;;AAEtD,AAAO,eA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GACH,MAAM;GACN,MAAM,CAAC,cAAc,EAAC;GACtB;EACD,CAAC;CACF;;;;"}
\ No newline at end of file \ No newline at end of file
...@@ -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) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment