1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Move S3 settings to environment variables

This commit is contained in:
Brett Sun 2016-06-24 16:14:16 +02:00
parent dbaf1a2e99
commit ba62734bdb
6 changed files with 35 additions and 18 deletions

View File

@ -1,9 +1,9 @@
# App settings
ONION_APP_VERSION=
ONION_API_URL=http://localhost.com:8000/api
ONION_API_URL=
ONION_BASE_PATH=
ONION_SERVER_URL=http://localhost.com:8000
ONION_SERVER_URL=
ONION_PORT=4000
@ -12,6 +12,8 @@ RAVEN_DSN_URL=
# S3 settings
S3_ACCESS_KEY=
S3_ACL=
S3_BUCKET=
# Dev server configuration
@ -20,6 +22,6 @@ ONION_DEV_PORT=3000
# Integration testing
SAUCE_USERNAME=ascribe
SAUCE_USERNAME=
SAUCE_ACCESS_KEY=
SAUCE_DEFAULT_URL=

View File

@ -16,12 +16,13 @@ import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
import { ErrorClasses, testErrorAgainstAll } from '../../constants/error_constants';
import { RETRY_ATTEMPT_TO_SHOW_CONTACT_US, ENDPOINTS } from '../../constants/uploader_constants';
import { RETRY_ATTEMPT_TO_SHOW_CONTACT_US, S3_ACCESS_KEY, S3_ACL, S3_BUCKET } from '../../constants/uploader_constants';
import { displayValidFilesFilter, FileStatus, transformAllowedExtensionsToInputAcceptProp } from './react_s3_fine_uploader_utils';
import { getCsrfToken, makeCsrfHeader } from '../../utils/csrf';
import { computeFileHash, createTextFile, extractFileExtensionFromString } from '../../utils/file';
import { getLangText } from '../../utils/lang';
import { resolveUrl } from '../../utils/url_resolver';
const { shape,
@ -167,12 +168,12 @@ const ReactS3FineUploader = React.createClass({
debug: false,
multiple: false,
objectProperties: {
acl: 'public-read',
bucket: 'ascribe0'
acl: S3_ACL,
bucket: S3_BUCKET
},
request: {
endpoint: ENDPOINTS.accelerate,
accessKey: 'AKIAIVCZJ33WSCBQ3QDA'
endpoint: resolveUrl('s3_accelerate'),
accessKey: S3_ACCESS_KEY
},
uploadSuccess: {
params: {

View File

@ -68,8 +68,12 @@ const ApiUrls = {
'webhooks': AppConstants.apiEndpoint + '/webhooks/',
'webhooks_events': AppConstants.apiEndpoint + '/webhooks/events/',
'whitelabel_settings': AppConstants.apiEndpoint + '/whitelabel/settings/${subdomain}/',
'delete_s3_file': AppConstants.serverUrl + '/s3/delete/',
'sign_url_s3': AppConstants.serverUrl + '/s3/sign_url/'
// S3 endpoints
's3': 'https://ascribe0.s3.amazonaws.com',
's3_accelerate': 'https://ascribe0.s3-accelerate.amazonaws.com',
's3_delete_file': `${AppConstants.serverUrl}/s3/delete/`,
's3_sign_url': `${AppConstants.serverUrl}/s3/sign_url/`
};
export function mergeWithBaseApiUrls(updatedApiUrls) {

View File

@ -1,5 +1,4 @@
'use strict';
// Validation types
export const validationParts = {
allowedExtensions: {
images: ['png', 'jpg', 'jpeg', 'gif']
@ -14,7 +13,7 @@ export const validationParts = {
}
};
const { allowedExtensions, itemLimit, sizeLimit } = validationParts;
const { itemLimit, sizeLimit } = validationParts;
export const validationTypes = {
additionalData: {
@ -34,7 +33,16 @@ export const validationTypes = {
// Number of manual retries before showing a contact us screen on the uploader.
export const RETRY_ATTEMPT_TO_SHOW_CONTACT_US = 5;
export const ENDPOINTS = {
s3: 'https://ascribe0.s3.amazonaws.com',
accelerate: 'https://ascribe0.s3-accelerate.amazonaws.com'
// S3 settings
export const S3_ACCESS_KEY = process.env.S3_ACCESS_KEY;
export const S3_ACL = process.env.S3_ACL;
export const S3_BUCKET = process.env.S3_BUCKET;
export default {
validationParts,
validationTypes,
RETRY_ATTEMPT_TO_SHOW_CONTACT_US,
S3_ACCESS_KEY,
S3_ACL,
S3_BUCKET
};

View File

@ -7,14 +7,14 @@ let S3Fetcher = {
* Fetch the registered applications of a user from the API.
*/
deleteFile(key, bucket) {
return request('delete_s3_file', {
return request('s3_delete_file', {
method: 'DELETE',
query: { bucket, key }
});
},
signUrl(key, title, artistName) {
return request('sign_url_s3', {
return request('s3_sign_url', {
query: { artistName, key, title }
});
}

View File

@ -45,6 +45,8 @@ const DEFINITIONS = {
RAVEN_DSN_URL: JSON.stringify(process.env.RAVEN_DSN_URL || ''),
S3_ACCESS_KEY: JSON.stringify(process.env.S3_ACCESS_KEY || ''),
S3_ACL: JSON.stringify(process.env.S3_ACL || 'public-read'),
S3_BUCKET: JSON.stringify(process.env.S3_BUCKET || 'ascribe0'),
},
};