mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-25 03:56:44 -06:00
Merge pull request #1990 from mei23/mei-osurl
オブジェクトストレージの参照URLを上書きできるようにする
This commit is contained in:
commit
8dd5051201
3 changed files with 27 additions and 1 deletions
|
@ -68,6 +68,29 @@ drive:
|
|||
# accessKey:
|
||||
# secretKey:
|
||||
|
||||
# S3 example
|
||||
# storage: 'minio'
|
||||
# bucket: bucket-name
|
||||
# prefix: files
|
||||
# config:
|
||||
# endPoint: s3-us-west-2.amazonaws.com
|
||||
# region: us-west-2
|
||||
# secure: true
|
||||
# accessKey: XXX
|
||||
# secretKey: YYY
|
||||
|
||||
# S3 example (with CDN, custom domain)
|
||||
# storage: 'minio'
|
||||
# bucket: drive.example.com
|
||||
# prefix: files
|
||||
# baseUrl: https://drive.example.com
|
||||
# config:
|
||||
# endPoint: s3-us-west-2.amazonaws.com
|
||||
# region: us-west-2
|
||||
# secure: true
|
||||
# accessKey: XXX
|
||||
# secretKey: YYY
|
||||
|
||||
#
|
||||
# Below settings are optional
|
||||
#
|
||||
|
|
|
@ -53,6 +53,7 @@ export type Source = {
|
|||
storage: string;
|
||||
bucket?: string;
|
||||
prefix?: string;
|
||||
baseUrl?: string;
|
||||
config?: any;
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ async function save(readable: stream.Readable, name: string, type: string, hash:
|
|||
const minio = new Minio.Client(config.drive.config);
|
||||
const id = uuid.v4();
|
||||
const obj = `${config.drive.prefix}/${id}`;
|
||||
const baseUrl = config.drive.baseUrl
|
||||
|| `${ config.drive.config.secure ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? ':' + config.drive.config.port : '' }/${ config.drive.bucket }`;
|
||||
await minio.putObject(config.drive.bucket, obj, readable, size, { 'Content-Type': type, 'Cache-Control': 'max-age=31536000, immutable' });
|
||||
|
||||
Object.assign(metadata, {
|
||||
|
@ -33,7 +35,7 @@ async function save(readable: stream.Readable, name: string, type: string, hash:
|
|||
storageProps: {
|
||||
id: id
|
||||
},
|
||||
url: `${ config.drive.config.secure ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? ':' + config.drive.config.port : '' }/${ config.drive.bucket }/${ obj }`
|
||||
url: `${ baseUrl }/${ obj }`
|
||||
});
|
||||
|
||||
const file = await DriveFile.insert({
|
||||
|
|
Loading…
Reference in a new issue