[noImplicitAny: true] src/services/drive
This commit is contained in:
parent
9d65415fdc
commit
daa409cd82
4 changed files with 14 additions and 5 deletions
|
@ -218,6 +218,7 @@
|
||||||
"xev": "2.0.1"
|
"xev": "2.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/file-type": "5.2.1",
|
||||||
"@types/jsdom": "11.0.5"
|
"@types/jsdom": "11.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import * as crypto from 'crypto';
|
||||||
import * as _gm from 'gm';
|
import * as _gm from 'gm';
|
||||||
import * as debug from 'debug';
|
import * as debug from 'debug';
|
||||||
import fileType = require('file-type');
|
import fileType = require('file-type');
|
||||||
import prominence = require('prominence');
|
const prominence = require('prominence');
|
||||||
|
|
||||||
import DriveFile, { IMetadata, getDriveFileBucket, IDriveFile } from '../../models/drive-file';
|
import DriveFile, { IMetadata, getDriveFileBucket, IDriveFile } from '../../models/drive-file';
|
||||||
import DriveFolder from '../../models/drive-folder';
|
import DriveFolder from '../../models/drive-folder';
|
||||||
|
@ -33,7 +33,7 @@ const writeChunks = (name: string, readable: stream.Readable, type: string, meta
|
||||||
readable.pipe(writeStream);
|
readable.pipe(writeStream);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const writeThumbnailChunks = (name: string, readable: stream.Readable, originalId) =>
|
const writeThumbnailChunks = (name: string, readable: stream.Readable, originalId: mongodb.ObjectID) =>
|
||||||
getDriveFileThumbnailBucket()
|
getDriveFileThumbnailBucket()
|
||||||
.then(bucket => new Promise((resolve, reject) => {
|
.then(bucket => new Promise((resolve, reject) => {
|
||||||
const writeStream = bucket.openUploadStream(name, {
|
const writeStream = bucket.openUploadStream(name, {
|
||||||
|
@ -89,7 +89,7 @@ export default async function(
|
||||||
const calcHash = new Promise<string>((res, rej) => {
|
const calcHash = new Promise<string>((res, rej) => {
|
||||||
const readable = fs.createReadStream(path);
|
const readable = fs.createReadStream(path);
|
||||||
const hash = crypto.createHash('md5');
|
const hash = crypto.createHash('md5');
|
||||||
const chunks = [];
|
const chunks: Buffer[] = [];
|
||||||
readable
|
readable
|
||||||
.on('error', rej)
|
.on('error', rej)
|
||||||
.pipe(hash)
|
.pipe(hash)
|
||||||
|
@ -201,7 +201,7 @@ export default async function(
|
||||||
return driveFolder;
|
return driveFolder;
|
||||||
};
|
};
|
||||||
|
|
||||||
const properties = {};
|
const properties: {[key: string]: any} = {};
|
||||||
|
|
||||||
let propPromises: Array<Promise<void>> = [];
|
let propPromises: Array<Promise<void>> = [];
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,12 @@ import * as request from 'request';
|
||||||
import { IDriveFile, validateFileName } from '../../models/drive-file';
|
import { IDriveFile, validateFileName } from '../../models/drive-file';
|
||||||
import create from './add-file';
|
import create from './add-file';
|
||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
|
import { IUser } from '../../models/user';
|
||||||
|
import * as mongodb from "mongodb";
|
||||||
|
|
||||||
const log = debug('misskey:drive:upload-from-url');
|
const log = debug('misskey:drive:upload-from-url');
|
||||||
|
|
||||||
export default async (url: string, user, folderId = null, uri: string = null): Promise<IDriveFile> => {
|
export default async (url: string, user: IUser, folderId: mongodb.ObjectID = null, uri: string = null): Promise<IDriveFile> => {
|
||||||
log(`REQUESTED: ${url}`);
|
log(`REQUESTED: ${url}`);
|
||||||
|
|
||||||
let name = URL.parse(url).pathname.split('/').pop();
|
let name = URL.parse(url).pathname.split('/').pop();
|
||||||
|
|
|
@ -176,6 +176,12 @@
|
||||||
version "1.3.0"
|
version "1.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/fancy-log/-/fancy-log-1.3.0.tgz#a61ab476e5e628cd07a846330df53b85e05c8ce0"
|
resolved "https://registry.yarnpkg.com/@types/fancy-log/-/fancy-log-1.3.0.tgz#a61ab476e5e628cd07a846330df53b85e05c8ce0"
|
||||||
|
|
||||||
|
"@types/file-type@5.2.1":
|
||||||
|
version "5.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/file-type/-/file-type-5.2.1.tgz#e7af49e08187b6b7598509c5e416669d25fa3461"
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
"@types/form-data@*":
|
"@types/form-data@*":
|
||||||
version "2.2.1"
|
version "2.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-2.2.1.tgz#ee2b3b8eaa11c0938289953606b745b738c54b1e"
|
resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-2.2.1.tgz#ee2b3b8eaa11c0938289953606b745b738c54b1e"
|
||||||
|
|
Loading…
Reference in a new issue