Merge branch 'main' of https://progit.zikor.pl/hamx/ArtisanConnectFrontend
This commit is contained in:
@@ -99,6 +99,11 @@ export async function getAllImagesByNoticeId(noticeId) {
|
||||
}
|
||||
|
||||
export const uploadImage = async (noticeId, imageUri) => {
|
||||
const { token } = useAuthStore.getState();
|
||||
const headers = {
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
'Content-Type': 'multipart/form-data'
|
||||
};
|
||||
const formData = new FormData();
|
||||
|
||||
const filename = imageUri.split("/").pop();
|
||||
@@ -107,7 +112,7 @@ export const uploadImage = async (noticeId, imageUri) => {
|
||||
const type = match ? `image/${match[1]}` : "image/jpeg";
|
||||
|
||||
formData.append("file", {
|
||||
uri: imageUri,
|
||||
uri: imageUri.uri,
|
||||
name: filename,
|
||||
type: type,
|
||||
});
|
||||
@@ -117,9 +122,7 @@ export const uploadImage = async (noticeId, imageUri) => {
|
||||
`${API_URL}/images/upload/${noticeId}`,
|
||||
formData,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
headers: headers,
|
||||
}
|
||||
);
|
||||
console.info("Upload successful:", response.data);
|
||||
|
||||
@@ -94,7 +94,6 @@ export default function CreateNotice() {
|
||||
try {
|
||||
const result = await addNotice({
|
||||
title: title,
|
||||
clientId: 1,
|
||||
description: description,
|
||||
price: price,
|
||||
category: category,
|
||||
|
||||
Reference in New Issue
Block a user