[#1500] Update sketch media file duplication code

- Sketch duplication code now checks for AWS endpoint via environment
  variable, rather than hard-coded string
- Fixes `aws.controller#getObjectKey`, which was incorrectly generating
  file keys
This commit is contained in:
Cassie Tarakajian 2020-07-16 17:00:50 -04:00
parent 4b3e00560b
commit cc6d868988
2 changed files with 4 additions and 2 deletions

View file

@ -16,6 +16,8 @@ import {
import { clearState, saveState } from '../../../persistState'; import { clearState, saveState } from '../../../persistState';
const ROOT_URL = getConfig('API_URL'); const ROOT_URL = getConfig('API_URL');
const S3_BUCKET_URL_BASE = getConfig('S3_BUCKET_URL_BASE');
const S3_BUCKET = getConfig('S3_BUCKET');
export function setProject(project) { export function setProject(project) {
return { return {
@ -287,7 +289,7 @@ export function cloneProject(id) {
// duplicate all files hosted on S3 // duplicate all files hosted on S3
each(newFiles, (file, callback) => { each(newFiles, (file, callback) => {
if (file.url && file.url.includes('amazonaws')) { if (file.url && (file.url.includes(S3_BUCKET_URL_BASE) || file.url.includes(S3_BUCKET))) {
const formParams = { const formParams = {
url: file.url url: file.url
}; };

View file

@ -28,7 +28,7 @@ function getExtension(filename) {
export function getObjectKey(url) { export function getObjectKey(url) {
const urlArray = url.split('/'); const urlArray = url.split('/');
let objectKey; let objectKey;
if (urlArray.length === 6) { if (urlArray.length === 5) {
const key = urlArray.pop(); const key = urlArray.pop();
const userId = urlArray.pop(); const userId = urlArray.pop();
objectKey = `${userId}/${key}`; objectKey = `${userId}/${key}`;