diff --git a/.env_template b/.env_template index aa8ed8ce..94bd5314 100644 --- a/.env_template +++ b/.env_template @@ -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= diff --git a/js/components/ascribe_uploader/react_s3_fine_uploader.js b/js/components/ascribe_uploader/react_s3_fine_uploader.js index 39f6fb16..27285bed 100644 --- a/js/components/ascribe_uploader/react_s3_fine_uploader.js +++ b/js/components/ascribe_uploader/react_s3_fine_uploader.js @@ -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: { diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js index 610e2e62..e1b23dd6 100644 --- a/js/constants/api_urls.js +++ b/js/constants/api_urls.js @@ -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) { diff --git a/js/constants/uploader_constants.js b/js/constants/uploader_constants.js index eec064df..bd251e4c 100644 --- a/js/constants/uploader_constants.js +++ b/js/constants/uploader_constants.js @@ -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 }; diff --git a/js/fetchers/s3_fetcher.js b/js/fetchers/s3_fetcher.js index a51d76b7..e45f5bdb 100644 --- a/js/fetchers/s3_fetcher.js +++ b/js/fetchers/s3_fetcher.js @@ -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 } }); } diff --git a/webpack.config.js b/webpack.config.js index 23f7a5a7..86ba60c1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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'), }, };