@team-monolith/cds 1.84.5 → 1.84.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,17 +24,30 @@ export function FileDownloadButton({ fileName, fileSize, fileUrl, }) {
24
24
  const handleDownload = () => __awaiter(this, void 0, void 0, function* () {
25
25
  var _a;
26
26
  const showFileError = (_a = cdsContext.lexical) === null || _a === void 0 ? void 0 : _a.showFileError;
27
- if (!fileUrl) {
28
- showFileError === null || showFileError === void 0 ? void 0 : showFileError("download", "다운로드 중 오류가 발생했어요");
27
+ try {
28
+ if (!fileUrl) {
29
+ showFileError === null || showFileError === void 0 ? void 0 : showFileError("download", "다운로드 중 오류가 발생했어요");
30
+ return;
31
+ }
32
+ const response = yield fetch(fileUrl, { method: "GET" });
33
+ if (!response.ok) {
34
+ showFileError === null || showFileError === void 0 ? void 0 : showFileError("download", "파일이 삭제되어 다운로드할 수 없어요.");
35
+ return;
36
+ }
37
+ const blob = yield response.blob();
38
+ const blobUrl = URL.createObjectURL(blob);
39
+ const link = document.createElement("a");
40
+ link.href = blobUrl;
41
+ link.download = fileName;
42
+ document.body.appendChild(link);
43
+ link.click();
44
+ document.body.removeChild(link);
45
+ URL.revokeObjectURL(blobUrl);
29
46
  }
30
- const response = yield fetch(fileUrl, { method: "HEAD" });
31
- if (!response.ok) {
32
- showFileError === null || showFileError === void 0 ? void 0 : showFileError("download", "파일이 삭제되어 다운로드할 수 없어요.");
47
+ catch (error) {
48
+ console.error("다운로드 실패:", error);
49
+ showFileError === null || showFileError === void 0 ? void 0 : showFileError("download", "파일을 다운로드할 수 없어요.");
33
50
  }
34
- const link = document.createElement("a");
35
- link.href = fileUrl;
36
- link.download = fileName;
37
- link.click();
38
51
  });
39
52
  return (_jsxs(ButtonContainer, Object.assign({ onClick: handleDownload, theme: theme }, { children: [_jsx(IconContainer, { children: getFileIcon(fileName) }), _jsx(FileNameLabel, { children: _jsx(OverflowTooltip, { text: fileName }) }), _jsxs(FileSize, { children: [(fileSize / (1024 * 1024)).toFixed(1), " MB"] })] })));
40
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.84.5",
3
+ "version": "1.84.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,