@bindu-dashing/dam-solution-v2 5.9.209 → 5.9.210
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.
|
@@ -19,7 +19,6 @@ import CustomButton from "../../common/Button";
|
|
|
19
19
|
import { showNotification } from "../../common/notifications";
|
|
20
20
|
import { FILE_UPLOAD_ERROR, SOMETHING_WENT_WRONG, UPDATE_SUCCESS, } from "../../utilities/constants/messages";
|
|
21
21
|
import { SAVE_EDITED_FILE_THUMBNAIL_URL, SAVE_EDITED_FILE_URL, } from "../../utilities/constants/apiUrls";
|
|
22
|
-
import axios from "axios";
|
|
23
22
|
import { generateFoldersQueryKey, invalidateData, QueryKeys, } from "../../utilities/constants/queryKeys";
|
|
24
23
|
import { useQueryClient } from "react-query";
|
|
25
24
|
import { useDamConfig } from "../../hocs/DamConfigContext";
|
|
@@ -50,12 +49,16 @@ const ImageEditorComponent = ({ file, handleClose, }) => {
|
|
|
50
49
|
const url = get(response, "data");
|
|
51
50
|
if (url) {
|
|
52
51
|
try {
|
|
53
|
-
|
|
52
|
+
// Use fetch instead of axios to avoid inheriting Authorization header
|
|
53
|
+
// from host app - S3 presigned URLs reject requests with Bearer tokens
|
|
54
|
+
const response = yield fetch(url, {
|
|
55
|
+
method: "PUT",
|
|
54
56
|
headers: {
|
|
55
57
|
"Content-Type": editedFile.type || "image/png",
|
|
56
58
|
},
|
|
59
|
+
body: editedFile,
|
|
57
60
|
});
|
|
58
|
-
if (
|
|
61
|
+
if (response.ok) {
|
|
59
62
|
try {
|
|
60
63
|
const result = yield api.put(SAVE_EDITED_FILE_THUMBNAIL_URL.replace(":fileId", get(file, "_id")), {});
|
|
61
64
|
invalidateData(queryClient, generateFoldersQueryKey(type), folderId ? folderId : rootFolderId);
|
|
@@ -70,6 +73,9 @@ const ImageEditorComponent = ({ file, handleClose, }) => {
|
|
|
70
73
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
|
|
71
74
|
}
|
|
72
75
|
}
|
|
76
|
+
else {
|
|
77
|
+
showNotification(FILE_UPLOAD_ERROR, NotificationStatus.ERROR);
|
|
78
|
+
}
|
|
73
79
|
}
|
|
74
80
|
catch (error) {
|
|
75
81
|
showNotification(get(error, "message", FILE_UPLOAD_ERROR), NotificationStatus.ERROR);
|