Skip to content

Commit

Permalink
feat: break everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Sembauke committed Nov 15, 2023
1 parent b7c6f50 commit ee06567
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 10 additions & 0 deletions apps/backend/config/plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = () => ({
upload: {
config: {
provider: "local",
providerOptions: {
sizeLimit: 100000,
},
},
},
});
1 change: 1 addition & 0 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@strapi/plugin-i18n": "4.15.4",
"@strapi/plugin-users-permissions": "4.15.4",
"@strapi/provider-email-nodemailer": "^4.12.4",
"@strapi/provider-upload-local": "^4.15.4",
"@strapi/strapi": "~4.15.0",
"nanoid": "^3.3.6",
"pg": "^8.11.3",
Expand Down
14 changes: 9 additions & 5 deletions apps/frontend/src/components/tiptap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ function ToolBar({ editor, user }) {
};

useEffect(() => {
const form = document.getElementById("choose-image-form");

const addImage = async () => {
const file = document.getElementById("feature-image").files[0];
const image = document.getElementById("feature-image").files[0];
const reader = new FileReader();
reader.readAsDataURL(file);
reader.readAsDataURL(image);
reader.onloadend = function () {
const base64data = reader.result;
editor.commands.setImage({
Expand All @@ -67,23 +69,25 @@ function ToolBar({ editor, user }) {
};
};

const form = document.getElementById("choose-image-form");

const handleSubmit = async (event) => {
event.preventDefault();

await addImage(event);

const apiURL = process.env.NEXT_PUBLIC_STRAPI_BACKEND_URL;
// const image = document.getElementById("feature-image").files;

// const formData = new FormData(event.target);

const res = await fetch(`${apiURL}/api/upload`, {
method: "post",
headers: {
Authorization: `Bearer ${user.jwt}`,
},
body: new FormData(event.target),
body: formData,
});
console.log(event.target);

console.log(res);
};

Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee06567

Please sign in to comment.