Skip to content

Commit

Permalink
Merge pull request #923 from basedosdados/development
Browse files Browse the repository at this point in the history
fix: download pro url
  • Loading branch information
AldemirLucas authored Aug 20, 2024
2 parents 4c0f6fe + e6d03e0 commit 31b0ca3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions next/pages/api/tables/downloadTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ async function validateToken(token) {

async function downloadTable(url, datasetID, tableId, token, res) {
let payloadToken
if(url !== "free") {
if(token !== null) payloadToken = await validateToken(token)
}
if(token !== null) payloadToken = await validateToken(token)

const urlDownloadOpen = process.env.URL_DOWNLOAD_OPEN.replace("gs://", "")
const urlDownloadClosed = process.env.URL_DOWNLOAD_CLOSED.replace("gs://", "")
Expand All @@ -32,10 +30,10 @@ async function downloadTable(url, datasetID, tableId, token, res) {
try {
let fileUrl = ""

if(url === "free") {
fileUrl =`${prefixUrl}${urlDownloadOpen}${datasetID}/${tableId}/${tableId}.csv.gz`
}else if(payloadToken?.pro_subscription_status === "active") {
if(payloadToken?.pro_subscription_status === "active") {
fileUrl = `${prefixUrl}${urlDownloadClosed}${datasetID}/${tableId}/${tableId}_bdpro.csv.gz`
}else if(url === "free") {
fileUrl =`${prefixUrl}${urlDownloadOpen}${datasetID}/${tableId}/${tableId}.csv.gz`
}

const response = await axios({
Expand Down

0 comments on commit 31b0ca3

Please sign in to comment.