}
w.Header().Set("Content-Type", "application/zip")
- w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
+ w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
// Create ZIP writer
zipWriter := zip.NewWriter(w)
if allowed {
w.Header().Set("Access-Control-Allow-Origin", origin)
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
- w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
+ w.Header().Set("Access-Control-Expose-Headers", "Content-Disposition")
+ w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, Content-Disposition")
w.Header().Set("Access-Control-Allow-Credentials", "true")
}
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
- a.download = `DailyTxT_Export_${localStorage.getItem('users')}.zip`;
+
+ const contentDisposition = response.headers['content-disposition'];
+ let filename = 'DailyTxT_Export.zip';
+ if (contentDisposition) {
+ const filenameMatch = contentDisposition.match(/filename="(.+)"/);
+ if (filenameMatch) {
+ filename = filenameMatch[1];
+ }
+ }
+
+ a.download = filename;
document.body.appendChild(a);
a.click();
a.remove();