harshcut
harshcut
Explore posts from servers
TTCTheo's Typesafe Cult
Created by harshcut on 4/10/2024 in #questions
Streaming file from Client to Server to S3
also this is the console log from req.file
{
fieldname: 'file',
originalname: 'FILE_NAME.pdf',
encoding: '7bit',
mimetype: 'application/pdf',
buffer: <Buffer >,
size: 0
}
{
fieldname: 'file',
originalname: 'FILE_NAME.pdf',
encoding: '7bit',
mimetype: 'application/pdf',
buffer: <Buffer >,
size: 0
}
14 replies
TTCTheo's Typesafe Cult
Created by harshcut on 4/10/2024 in #questions
Streaming file from Client to Server to S3
No description
14 replies
TTCTheo's Typesafe Cult
Created by harshcut on 4/10/2024 in #questions
Streaming file from Client to Server to S3
data is an internal variable in a library.
server:dev: /home/harsh/Documents/GitHub/s3-upload/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js:160 server:dev: if (typeof data.stream === "function") { server:dev: ^ server:dev: TypeError: Cannot read properties of undefined (reading 'stream') server:dev: at getChunk (/home/harsh/Documents/GitHub/s3-upload/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js:160:19) server:dev: at _Upload.__doMultipartUpload (/home/harsh/Documents/GitHub/s3-upload/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js:374:24)
14 replies
TTCTheo's Typesafe Cult
Created by harshcut on 4/10/2024 in #questions
Streaming file from Client to Server to S3
The answer is yes.
@JulieCezar I don't think the file is streamable when sending it using formData. Below is the code I'm using on my Express server and it throws an error.
import { Upload } from '@aws-sdk/lib-storage'
const upload = multer()
...
app.post('/upload', checkAuthentication, upload.single('file'), uploadStream)
...
export const uploadStream = async (req, res) => {
const fileId = crypto.randomUUID()
const parallelUploads3 = new Upload({
client: s3,
params: {
Bucket: bucketName,
Key: fileId,
Body: file.stream
// ?^ stream does not exist on file object
},
queueSize: 1,
})
}
import { Upload } from '@aws-sdk/lib-storage'
const upload = multer()
...
app.post('/upload', checkAuthentication, upload.single('file'), uploadStream)
...
export const uploadStream = async (req, res) => {
const fileId = crypto.randomUUID()
const parallelUploads3 = new Upload({
client: s3,
params: {
Bucket: bucketName,
Key: fileId,
Body: file.stream
// ?^ stream does not exist on file object
},
queueSize: 1,
})
}
if (typeof data.stream === "function") { ^ TypeError: Cannot read properties of undefined (reading 'stream')
14 replies
TTCTheo's Typesafe Cult
Created by harshcut on 4/10/2024 in #questions
Streaming file from Client to Server to S3
I am creating this app as an excersise to learn and understand streams and piping data, and won't probably use presigned url logic.
14 replies
TTCTheo's Typesafe Cult
Created by harshcut on 4/10/2024 in #questions
Streaming file from Client to Server to S3
Few questions: 1. When uploading a large file from the client to s3, what should be the expiry for the presignedPostURL? 2. I also want to save the file metadata on a MongoDB database. So, do I make a POST request again to Express to save data to MongoDB after the upload is complete? Or, maybe I could add upload_state as pending on the initial request to get the presignedPostURL?
14 replies
TTCTheo's Typesafe Cult
Created by harshcut on 2/25/2024 in #questions
`MaxListenersExceededWarning` on using `tailFile.on` inside `socket` connection
some more information that might help: - i will only push update data to connections, and won't receive any from them - every new connection will be sent init data, and thereafter only update data
2 replies
TTCTheo's Typesafe Cult
Created by harshcut on 7/2/2023 in #questions
importing data into [slug]
wont be server rendered 😦
20 replies
TTCTheo's Typesafe Cult
Created by harshcut on 7/2/2023 in #questions
importing data into [slug]
the shared stuff will all go into layout.tsx and yes, the specific stuff could be added from props
20 replies
TTCTheo's Typesafe Cult
Created by harshcut on 7/2/2023 in #questions
importing data into [slug]
currently am i hardcoding the pages. i thought there might an easy way with slugs, as i could just plug the components and write the reusable functions directly into [slug]/page.tsx
20 replies
TTCTheo's Typesafe Cult
Created by harshcut on 7/2/2023 in #questions
importing data into [slug]
i was thinking the same thing, but i dont think this the right way
20 replies
TTCTheo's Typesafe Cult
Created by harshcut on 7/2/2023 in #questions
importing data into [slug]
is there an example repo?
20 replies
TTCTheo's Typesafe Cult
Created by harshcut on 7/2/2023 in #questions
importing data into [slug]
i know how to get the id. currently this is my file structure /craft/page.tsx /craft/craft-1/page.tsx /craft/craft-2/page.tsx each craft-n/page has different client react components. how do i store these pages and import them depending upon the id
20 replies
TTCTheo's Typesafe Cult
Created by H on 6/20/2023 in #questions
Ui component name
i made this some time ago
5 replies
TTCTheo's Typesafe Cult
Created by H on 6/20/2023 in #questions
Ui component name
5 replies
TTCTheo's Typesafe Cult
Created by harshcut on 6/18/2023 in #questions
is this the correct use of usecallback?
also how to check if a function (in this case foo) is recreated or not?
7 replies
TTCTheo's Typesafe Cult
Created by harshcut on 4/21/2023 in #questions
help with prisma schema (coming from sql)
User[] seems like a good place to start, and Slot and slotId are added by prisma extension.
3 replies
TTCTheo's Typesafe Cult
Created by harshcut on 4/21/2023 in #questions
help with prisma schema (coming from sql)
I want to create a collections named Slot with id, timestamp, and an array of objects which are from User collection. How do I do it?
3 replies
TTCTheo's Typesafe Cult
Created by harshcut on 2/15/2023 in #questions
Compiling TailwindCSS for Monorepos
consume packages/ui directly from source without building
while doing this i do need to add transpilePackages: ['ui'], to next.config, right? so that next can bundle it?
18 replies
TTCTheo's Typesafe Cult
Created by harshcut on 2/15/2023 in #questions
Compiling TailwindCSS for Monorepos
this way i dont need to include a ./dist/index.css in _app.tsx in client.
18 replies