compatible with sharex custom uploader

This commit is contained in:
Erik 2022-03-26 14:42:36 +02:00
parent 53c6f6448c
commit 22a174c7e1
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589
3 changed files with 8 additions and 4 deletions

View File

@ -66,7 +66,7 @@ class ClipIndex extends EventEmitter {
fs.writeFileSync(this.indexDir, JSON.stringify(this.index));
this.emit('upload', this.index[filename]);
resolve();
resolve(this.index[filename]);
});

View File

@ -40,6 +40,7 @@ class Client extends EventEmitter {
this.port = parseInt(env.HTTP_PORT) + this.shardId;
this.domain = env.NODE_ENV === 'production' ? env.DOMAIN : `localhost`;
this.proto = env.NODE_ENV === 'production' ? 'https' : 'http';
this.baseUrl = `${this.proto}://${this.domain}`;
this.baseDirectory = path.resolve(__dirname, '../..');
this.mediaDirectory = path.join(this.baseDirectory, opts.media.videos);

View File

@ -37,10 +37,13 @@ class Login extends APIEndpoint {
this.logger.info(`${req.user.username}#${req.user.discriminator} is uploading ${name}`);
try {
await this.client.clipIndex.add(file, name, req.user);
res.status(200).end();
const result = await this.client.clipIndex.add(file, name, req.user);
res.status(200).json({
url: `${this.client.baseUrl}/media/${name}`,
thumbnail: `${this.client.baseUrl}/thumbnails/${result.thumbnail}`
});
} catch (_) {
res.status(500).end();
res.status(500).send('Internal error');
}
}