FakeS3 support
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
// @flow
|
||||
import uuid from 'uuid';
|
||||
import Router from 'koa-router';
|
||||
|
||||
import { makePolicy, signPolicy } from '../utils/s3';
|
||||
import { makePolicy, signPolicy, publicS3Endpoint } from '../utils/s3';
|
||||
import auth from './middlewares/authentication';
|
||||
import { presentUser } from '../presenters';
|
||||
|
||||
@ -21,11 +20,12 @@ router.post('user.s3Upload', auth(), async ctx => {
|
||||
const s3Key = uuid.v4();
|
||||
const key = `uploads/${ctx.state.user.id}/${s3Key}/${filename}`;
|
||||
const policy = makePolicy();
|
||||
const endpoint = publicS3Endpoint();
|
||||
|
||||
ctx.body = {
|
||||
data: {
|
||||
maxUploadSize: process.env.AWS_S3_UPLOAD_MAX_SIZE,
|
||||
uploadUrl: process.env.AWS_S3_UPLOAD_BUCKET_URL,
|
||||
uploadUrl: endpoint,
|
||||
form: {
|
||||
AWSAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
||||
'Cache-Control': 'max-age=31557600',
|
||||
@ -37,7 +37,7 @@ router.post('user.s3Upload', auth(), async ctx => {
|
||||
},
|
||||
asset: {
|
||||
contentType: kind,
|
||||
url: `${process.env.AWS_S3_UPLOAD_BUCKET_URL}${key}`,
|
||||
url: `${endpoint}/${key}`,
|
||||
name: filename,
|
||||
size,
|
||||
},
|
||||
|
Reference in New Issue
Block a user