Spaces:
Sleeping
Sleeping
Commit ·
a158e71
1
Parent(s): 9ca21f5
Fix file preview URLs by routing through backend download endpoint
Browse files- js/main.js +2 -2
- js/utils/formatters.js +2 -2
js/main.js
CHANGED
|
@@ -238,7 +238,7 @@ class App {
|
|
| 238 |
onDownload: (url, name) => this.downloadFile(url, name),
|
| 239 |
onStar: (path) => this.state.toggleStar(path),
|
| 240 |
onDelete: (path, name) => this.openDeleteModal(path, name),
|
| 241 |
-
getUrl: (path) => getFileUrl(this.hf.
|
| 242 |
});
|
| 243 |
|
| 244 |
this.updateActiveNavItem();
|
|
@@ -359,7 +359,7 @@ class App {
|
|
| 359 |
|
| 360 |
openPreview(file) {
|
| 361 |
this.state.addToRecent(file);
|
| 362 |
-
const url = getFileUrl(this.hf.
|
| 363 |
const modal = document.getElementById('previewModal');
|
| 364 |
const body = document.getElementById('previewBody');
|
| 365 |
const title = document.getElementById('previewFileName');
|
|
|
|
| 238 |
onDownload: (url, name) => this.downloadFile(url, name),
|
| 239 |
onStar: (path) => this.state.toggleStar(path),
|
| 240 |
onDelete: (path, name) => this.openDeleteModal(path, name),
|
| 241 |
+
getUrl: (path) => getFileUrl(this.hf.apiBase, path)
|
| 242 |
});
|
| 243 |
|
| 244 |
this.updateActiveNavItem();
|
|
|
|
| 359 |
|
| 360 |
openPreview(file) {
|
| 361 |
this.state.addToRecent(file);
|
| 362 |
+
const url = getFileUrl(this.hf.apiBase, file.path);
|
| 363 |
const modal = document.getElementById('previewModal');
|
| 364 |
const body = document.getElementById('previewBody');
|
| 365 |
const title = document.getElementById('previewFileName');
|
js/utils/formatters.js
CHANGED
|
@@ -57,7 +57,7 @@ export function formatDate(timestamp) {
|
|
| 57 |
return `${Math.floor(diffDays / 365)} years ago`;
|
| 58 |
}
|
| 59 |
|
| 60 |
-
export function getFileUrl(
|
| 61 |
const encoded = filePath.split('/').map(encodeURIComponent).join('/');
|
| 62 |
-
return `
|
| 63 |
}
|
|
|
|
| 57 |
return `${Math.floor(diffDays / 365)} years ago`;
|
| 58 |
}
|
| 59 |
|
| 60 |
+
export function getFileUrl(apiBase, filePath) {
|
| 61 |
const encoded = filePath.split('/').map(encodeURIComponent).join('/');
|
| 62 |
+
return `${apiBase}/download/${encoded}`;
|
| 63 |
}
|