Switch from restler to unirest
restler is buggy and doesn't support utf8 multipart requests
This commit is contained in:
@ -1,8 +1,5 @@
|
||||
import Base from './Base';
|
||||
import mime from 'mime';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import restler from 'restler';
|
||||
|
||||
const TYPES = ['photo', 'video', 'document', 'audio'];
|
||||
|
||||
@ -40,14 +37,11 @@ export default class File extends Base {
|
||||
*/
|
||||
file(file, fileType) {
|
||||
if (fileType) {
|
||||
this.properties[fileType] = file;
|
||||
this.properties[fileType] = {file: file};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
const stat = fs.statSync(file);
|
||||
const name = path.basename(file);
|
||||
|
||||
let [type, extension] = mime.lookup(file).split('/');
|
||||
if (type === 'image') {
|
||||
type = 'photo';
|
||||
@ -61,7 +55,7 @@ export default class File extends Base {
|
||||
type = 'document';
|
||||
}
|
||||
|
||||
this.properties[type] = restler.file(file, name, stat.size, 'utf-8');
|
||||
this.properties[type] = {file: file};
|
||||
|
||||
this.method = `send${type[0].toUpperCase() + type.slice(1)}`;
|
||||
|
||||
|
Reference in New Issue
Block a user