diff --git a/src/backend/app/projects/project_routes.py b/src/backend/app/projects/project_routes.py index 29c3f669db..95cebed873 100644 --- a/src/backend/app/projects/project_routes.py +++ b/src/backend/app/projects/project_routes.py @@ -1062,19 +1062,7 @@ async def download_tiles(tile_id: int, db: Session = Depends(database.get_db)): .first() ) log.info(f"User requested download for tiles: {tiles_path.path}") - - project_id = tiles_path.project_id - project = await project_crud.get_project(db, project_id) - project_name = project.project_name_prefix - filename = Path(tiles_path.path).name.replace( - f"{project_id}_", f"{project_name.replace(' ', '_')}_" - ) - log.debug(f"Sending tile archive to user: {filename}") - - return FileResponse( - tiles_path.path, - headers={"Content-Disposition": f'attachment; filename="{filename}"'}, - ) + return RedirectResponse(tiles_path.path) @router.get("/boundary_in_osm/{project_id}/") diff --git a/src/frontend/src/api/Project.js b/src/frontend/src/api/Project.js index 225ec0fc74..2da999f8ab 100755 --- a/src/frontend/src/api/Project.js +++ b/src/frontend/src/api/Project.js @@ -160,34 +160,6 @@ export const GenerateProjectTiles = (url, payload) => { }; }; -export const DownloadTile = (url, payload) => { - return async (dispatch) => { - dispatch(ProjectActions.SetDownloadTileLoading({ type: payload, loading: true })); - - const getDownloadTile = async (url, payload) => { - try { - const response = await CoreModules.axios.get(url, { - responseType: 'blob', - }); - - // Get filename from content-disposition header - const filename = response.headers['content-disposition'].split('filename=')[1]; - - var a = document.createElement('a'); - a.href = window.URL.createObjectURL(response.data); - a.download = filename; - a.click(); - dispatch(ProjectActions.SetDownloadTileLoading({ type: payload, loading: false })); - } catch (error) { - dispatch(ProjectActions.SetDownloadTileLoading({ type: payload, loading: false })); - } finally { - dispatch(ProjectActions.SetDownloadTileLoading({ type: payload, loading: false })); - } - }; - await getDownloadTile(url, payload); - }; -}; - export const GetProjectDashboard = (url) => { return async (dispatch) => { const getProjectDashboard = async (url) => { diff --git a/src/frontend/src/components/GenerateBasemap.jsx b/src/frontend/src/components/GenerateBasemap.jsx index bc6c5bfcd9..55d4698be7 100644 --- a/src/frontend/src/components/GenerateBasemap.jsx +++ b/src/frontend/src/components/GenerateBasemap.jsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import CoreModules from '../shared/CoreModules'; import AssetModules from '../shared/AssetModules'; import environment from '../environment'; -import { DownloadTile, GenerateProjectTiles, GetTilesList } from '../api/Project'; +import { GenerateProjectTiles, GetTilesList } from '../api/Project'; const GenerateBasemap = ({ setToggleGenerateModal, toggleGenerateModal, projectInfo }) => { const dispatch = CoreModules.useAppDispatch(); @@ -25,8 +25,8 @@ const GenerateBasemap = ({ setToggleGenerateModal, toggleGenerateModal, projectI padding: '16px 32px 24px 32px', maxWidth: '1000px', }); - const downloadBasemap = (tileId) => { - dispatch(DownloadTile(`${import.meta.env.VITE_API_URL}/projects/download_tiles/?tile_id=${tileId}`, projectInfo)); + const downloadBasemap = async (tileId) => { + window.open(`${import.meta.env.VITE_API_URL}/projects/download_tiles/?tile_id=${tileId}`, '_blank'); }; const getTilesList = () => { diff --git a/src/frontend/src/store/slices/ProjectSlice.ts b/src/frontend/src/store/slices/ProjectSlice.ts index 20a82bdf03..739b5b9e67 100755 --- a/src/frontend/src/store/slices/ProjectSlice.ts +++ b/src/frontend/src/store/slices/ProjectSlice.ts @@ -16,7 +16,6 @@ const ProjectSlice = createSlice({ generateProjectTilesLoading: false, tilesList: [], tilesListLoading: false, - downloadTilesLoading: false, downloadDataExtractLoading: false, taskModalStatus: false, mobileFooterSelection: 'explore', @@ -66,9 +65,6 @@ const ProjectSlice = createSlice({ SetTilesListLoading(state, action) { state.tilesListLoading = action.payload; }, - SetDownloadTileLoading(state, action) { - state.downloadTilesLoading = action.payload; - }, SetDownloadDataExtractLoading(state, action) { state.downloadDataExtractLoading = action.payload; },