compatible with sharex custom uploader
This commit is contained in:
parent
53c6f6448c
commit
22a174c7e1
@ -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]);
|
||||
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user