Skip to content

Commit

Permalink
sending the image with MIME type in the ArrayBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Franqsanz committed Oct 30, 2023
1 parent a84cf0f commit 8cb46dd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
51 changes: 24 additions & 27 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"@emotion/styled": "11.11.0",
"@tanstack/react-query": "4.29.19",
"@tanstack/react-query-devtools": "4.29.19",
"browser-image-compression": "2.0.2",
"chakra-react-select": "4.6.0",
"firebase": "10.1.0",
"framer-motion": "10.12.17",
"million": "2.5.10",
"nanoid": "4.0.2",
"pako": "2.1.0",
"react": "18.2.0",
"react-cropper": "2.3.3",
"react-dom": "18.2.0",
Expand All @@ -49,6 +49,7 @@
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.0.0",
"@types/cypress": "1.1.3",
"@types/pako": "2.0.2",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"@typescript-eslint/eslint-plugin": "6.0.0",
Expand Down
12 changes: 9 additions & 3 deletions src/components/forms/NewBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Skeleton,
FormErrorMessage,
} from '@chakra-ui/react';
// import compressImage from 'browser-image-compression';
import pako from 'pako';
import { useForm } from 'react-hook-form';
import { Select } from 'chakra-react-select';
import 'cropperjs/dist/cropper.css';
Expand Down Expand Up @@ -177,7 +177,13 @@ export function FormNewBook() {
const arrayBuffer = reader.result as ArrayBuffer;
const uint8Array = new Uint8Array(arrayBuffer);
const byteArray = [...uint8Array];

// const compressedArrayBuffer = pako.deflate(
// new Uint8Array(arrayBuffer),
// );
// const byteArray = [...new Uint8Array(compressedArrayBuffer)];
// console.log(arrayBuffer);
// console.log(uint8Array);
// console.log(byteArray);
setBooks((prevBooks) => ({
...prevBooks,
image: {
Expand All @@ -190,7 +196,7 @@ export function FormNewBook() {

onClose();
}
});
}, 'image/webp');
}
}

Expand Down

1 comment on commit 8cb46dd

@vercel
Copy link

@vercel vercel bot commented on 8cb46dd Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

xbu – ./

xbu.vercel.app
xbu-git-main-franqsanz.vercel.app
xbu-franqsanz.vercel.app

Please sign in to comment.