Skip to content

Commit

Permalink
fix(download): fix other instances of s3 downloads
Browse files Browse the repository at this point in the history
refs #190
  • Loading branch information
landonreed committed Jun 5, 2018
1 parent 52efd96 commit d2498eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
10 changes: 5 additions & 5 deletions lib/editor/actions/snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {createAction} from 'redux-actions'
import {secureFetch} from '../../common/actions'
import {getConfigProperty} from '../../common/util/config'
import {handleJobResponse} from '../../manager/actions/status'
import {downloadS3Key} from '../../manager/actions/versions'

const requestingSnapshots = createAction('REQUESTING_GTFSEDITOR_SNAPSHOTS')
const receiveSnapshots = createAction('RECEIVE_GTFSEDITOR_SNAPSHOTS')
Expand Down Expand Up @@ -60,12 +59,13 @@ export function downloadSnapshotViaCredentials (snapshot, isPublic, prefix) {
const url = `/api/editor/${route}/snapshot/${snapshot.id}/downloadtoken?feedId=${snapshot.feedSourceId}`
return dispatch(secureFetch(url))
.then(response => response.json())
.then(credentials => {
.then(json => {
if (getConfigProperty('application.data.use_s3_storage')) {
dispatch(downloadS3Key(credentials, `${snapshot.id}.zip`, 'snapshots'))
// Download object using presigned S3 URL.
window.location.assign(json.url)
} else {
// use token to download feed
window.location.assign(`/api/editor/downloadsnapshot/${credentials.id}`)
// Use token to download feed
window.location.assign(`/api/editor/downloadsnapshot/${json.id}`)
}
})
}
Expand Down
21 changes: 11 additions & 10 deletions lib/manager/actions/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,16 @@ export function downloadMergedFeedViaToken (project, isPublic, prefix) {
return function (dispatch, getState) {
const route = isPublic ? 'public' : 'secure'
const url = `/api/manager/${route}/project/${project.id}/downloadtoken`
dispatch(secureFetch(url))
.then(response => response.json())
.then(credentials => {
if (getConfigProperty('application.data.use_s3_storage')) {
dispatch(downloadS3Key(credentials, `${project.id}.zip`, 'project'))
} else {
// use token to download feed
window.location.assign(`/api/manager/downloadprojectfeed/${credentials.id}`)
}
})
return dispatch(secureFetch(url))
.then(response => response.json())
.then(json => {
if (getConfigProperty('application.data.use_s3_storage')) {
// Download object using presigned S3 URL.
window.location.assign(json.url)
} else {
// use token to download feed
window.location.assign(`/api/manager/downloadprojectfeed/${json.id}`)
}
})
}
}
2 changes: 1 addition & 1 deletion lib/manager/actions/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export function downloadFeedViaToken (feedVersion, isPublic, prefix = 'gtfs') {
.then(response => response.json())
.then(json => {
if (getConfigProperty('application.data.use_s3_storage')) {
// Download object using presigned URL.
// Download object using presigned S3 URL.
window.location.assign(json.url)
} else {
// Otherwise, use the provided token to download feed from the server.
Expand Down

0 comments on commit d2498eb

Please sign in to comment.