Option objectStorageSetPublicRead (#6645)

This commit is contained in:
MeiMei 2020-08-13 20:05:01 +09:00 committed by GitHub
parent bb342c7601
commit ee0a445590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 0 deletions

View File

@ -468,6 +468,7 @@ objectStorageUseSSL: "SSLを使用する"
objectStorageUseSSLDesc: "API接続にhttpsを使用しない場合はオフにしてください" objectStorageUseSSLDesc: "API接続にhttpsを使用しない場合はオフにしてください"
objectStorageUseProxy: "Proxyを利用する" objectStorageUseProxy: "Proxyを利用する"
objectStorageUseProxyDesc: "API接続にproxyを利用しない場合はオフにしてください" objectStorageUseProxyDesc: "API接続にproxyを利用しない場合はオフにしてください"
objectStorageSetPublicRead: "アップロード時に'public-read'を設定する"
serverLogs: "サーバーログ" serverLogs: "サーバーログ"
deleteAll: "全て削除" deleteAll: "全て削除"
showFixedPostForm: "タイムライン上部に投稿フォームを表示する" showFixedPostForm: "タイムライン上部に投稿フォームを表示する"

View File

@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from "typeorm";
export class objectStorageSetPublicRead1597230137744 implements MigrationInterface {
name = 'objectStorageSetPublicRead1597230137744'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "meta" ADD "objectStorageSetPublicRead" boolean NOT NULL DEFAULT false`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "objectStorageSetPublicRead"`);
}
}

View File

@ -161,6 +161,7 @@
</div> </div>
<mk-switch v-model="objectStorageUseSSL" :disabled="!useObjectStorage">{{ $t('objectStorageUseSSL') }}<template #desc>{{ $t('objectStorageUseSSLDesc') }}</template></mk-switch> <mk-switch v-model="objectStorageUseSSL" :disabled="!useObjectStorage">{{ $t('objectStorageUseSSL') }}<template #desc>{{ $t('objectStorageUseSSLDesc') }}</template></mk-switch>
<mk-switch v-model="objectStorageUseProxy" :disabled="!useObjectStorage">{{ $t('objectStorageUseProxy') }}<template #desc>{{ $t('objectStorageUseProxyDesc') }}</template></mk-switch> <mk-switch v-model="objectStorageUseProxy" :disabled="!useObjectStorage">{{ $t('objectStorageUseProxy') }}<template #desc>{{ $t('objectStorageUseProxyDesc') }}</template></mk-switch>
<mk-switch v-model="objectStorageSetPublicRead" :disabled="!useObjectStorage">{{ $t('objectStorageSetPublicRead') }}</mk-switch>
</template> </template>
</div> </div>
<div class="_footer"> <div class="_footer">
@ -306,6 +307,7 @@ export default Vue.extend({
objectStorageSecretKey: null, objectStorageSecretKey: null,
objectStorageUseSSL: false, objectStorageUseSSL: false,
objectStorageUseProxy: false, objectStorageUseProxy: false,
objectStorageSetPublicRead: false,
enableTwitterIntegration: false, enableTwitterIntegration: false,
twitterConsumerKey: null, twitterConsumerKey: null,
twitterConsumerSecret: null, twitterConsumerSecret: null,
@ -373,6 +375,7 @@ export default Vue.extend({
this.objectStorageSecretKey = this.meta.objectStorageSecretKey; this.objectStorageSecretKey = this.meta.objectStorageSecretKey;
this.objectStorageUseSSL = this.meta.objectStorageUseSSL; this.objectStorageUseSSL = this.meta.objectStorageUseSSL;
this.objectStorageUseProxy = this.meta.objectStorageUseProxy; this.objectStorageUseProxy = this.meta.objectStorageUseProxy;
this.objectStorageSetPublicRead = this.meta.objectStorageSetPublicRead;
this.enableTwitterIntegration = this.meta.enableTwitterIntegration; this.enableTwitterIntegration = this.meta.enableTwitterIntegration;
this.twitterConsumerKey = this.meta.twitterConsumerKey; this.twitterConsumerKey = this.meta.twitterConsumerKey;
this.twitterConsumerSecret = this.meta.twitterConsumerSecret; this.twitterConsumerSecret = this.meta.twitterConsumerSecret;
@ -522,6 +525,7 @@ export default Vue.extend({
objectStorageSecretKey: this.objectStorageSecretKey ? this.objectStorageSecretKey : null, objectStorageSecretKey: this.objectStorageSecretKey ? this.objectStorageSecretKey : null,
objectStorageUseSSL: this.objectStorageUseSSL, objectStorageUseSSL: this.objectStorageUseSSL,
objectStorageUseProxy: this.objectStorageUseProxy, objectStorageUseProxy: this.objectStorageUseProxy,
objectStorageSetPublicRead: this.objectStorageSetPublicRead,
enableTwitterIntegration: this.enableTwitterIntegration, enableTwitterIntegration: this.enableTwitterIntegration,
twitterConsumerKey: this.twitterConsumerKey, twitterConsumerKey: this.twitterConsumerKey,
twitterConsumerSecret: this.twitterConsumerSecret, twitterConsumerSecret: this.twitterConsumerSecret,

View File

@ -370,4 +370,9 @@ export class Meta {
default: true, default: true,
}) })
public objectStorageUseProxy: boolean; public objectStorageUseProxy: boolean;
@Column('boolean', {
default: false,
})
public objectStorageSetPublicRead: boolean;
} }

View File

@ -418,6 +418,10 @@ export const meta = {
objectStorageUseProxy: { objectStorageUseProxy: {
validator: $.optional.bool validator: $.optional.bool
},
objectStorageSetPublicRead: {
validator: $.optional.bool
} }
} }
}; };
@ -673,6 +677,10 @@ export default define(meta, async (ps, me) => {
set.objectStorageUseProxy = ps.objectStorageUseProxy; set.objectStorageUseProxy = ps.objectStorageUseProxy;
} }
if (ps.objectStorageSetPublicRead !== undefined) {
set.objectStorageSetPublicRead = ps.objectStorageSetPublicRead;
}
await getConnection().transaction(async transactionalEntityManager => { await getConnection().transaction(async transactionalEntityManager => {
const meta = await transactionalEntityManager.findOne(Meta, { const meta = await transactionalEntityManager.findOne(Meta, {
order: { order: {

View File

@ -195,6 +195,7 @@ export default define(meta, async (ps, me) => {
response.objectStorageSecretKey = instance.objectStorageSecretKey; response.objectStorageSecretKey = instance.objectStorageSecretKey;
response.objectStorageUseSSL = instance.objectStorageUseSSL; response.objectStorageUseSSL = instance.objectStorageUseSSL;
response.objectStorageUseProxy = instance.objectStorageUseProxy; response.objectStorageUseProxy = instance.objectStorageUseProxy;
response.objectStorageSetPublicRead = instance.objectStorageSetPublicRead;
} }
return response; return response;

View File

@ -212,6 +212,7 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string,
} as S3.PutObjectRequest; } as S3.PutObjectRequest;
if (filename) params.ContentDisposition = contentDisposition('inline', filename); if (filename) params.ContentDisposition = contentDisposition('inline', filename);
if (meta.objectStorageSetPublicRead) params.ACL = 'public-read';
const s3 = getS3(meta); const s3 = getS3(meta);