Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import axios from "axios";

type CSVFileImportProps = {
url: string;
Expand All @@ -24,23 +25,30 @@ export default function CSVFileImport({ url, title }: CSVFileImportProps) {

const uploadFile = async () => {
console.log("uploadFile to", url);
console.log('file', file);

// Get the presigned URL
// const response = await axios({
// method: "GET",
// url,
// params: {
// name: encodeURIComponent(file.name),
// },
// });
// console.log("File to upload: ", file.name);
// console.log("Uploading to: ", response.data);
// const result = await fetch(response.data, {
// method: "PUT",
// body: file,
// });
// console.log("Result: ", result);
// setFile("");

if (file) {
// Get the presigned URL
const { data: { signedUrl }} = await axios({
method: "GET",
url,
params: {
name: encodeURIComponent(file.name),
},
});
console.log("File to upload: ", file.name);
console.log("Uploading to: ", signedUrl);
const result = await fetch(signedUrl, {
mode: 'no-cors',
method: "PUT",
body: file,
});
console.log("Result: ", result);
setFile(undefined);
} else {
throw new Error('File is undefined');
}
};
return (
<Box>
Expand Down
4 changes: 2 additions & 2 deletions src/constants/apiPaths.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const API_PATHS = {
product: "https://.execute-api.eu-west-1.amazonaws.com/dev",
order: "https://.execute-api.eu-west-1.amazonaws.com/dev",
import: "https://.execute-api.eu-west-1.amazonaws.com/dev",
bff: "https://.execute-api.eu-west-1.amazonaws.com/dev",
import: "https://rzzqm10d2k.execute-api.us-east-1.amazonaws.com/dev",
bff: "https://rzzqm10d2k.execute-api.us-east-1.amazonaws.com/dev",
cart: "https://.execute-api.eu-west-1.amazonaws.com/dev",
};

Expand Down