psygo
psygo
Explore posts from servers
TTCTheo's Typesafe Cult
Created by psygo on 5/1/2024 in #questions
Converting String Encoded Images to Files to upload with UploadThing
In my app, I'm using a libary which handles files in a file manager as base 64 strings. Is there a practical way of uploading string encoded images with UT? If not, here's what I've been trying (the rest of the code is basically the docs' default setup):
const url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="
const f = new File(
[new Blob([url.split(",")[1]!])],
"a",
{ type: "image/png" },
)
const selectedFiles = Array.from([f])
const result = await startUpload(selectedFiles)
const url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="
const f = new File(
[new Blob([url.split(",")[1]!])],
"a",
{ type: "image/png" },
)
const selectedFiles = Array.from([f])
const result = await startUpload(selectedFiles)
When I try this, I get this error:
⨯ UPLOADTHING 12:51:02 PM Invalid config: UnknownFileType
⨯ UPLOADTHING 12:51:02 PM Invalid config: UnknownFileType
I've also tried the many other ways of converting image strings to binaries, e.g. these.
4 replies
SSolidJS
Created by psygo on 8/17/2023 in #support
D3 Force Graph in SolidJS with TypeScript
I've originally asked this on StackOverflow.
D3 seems so complicated to make work with basically any framework... Specially when it comes to TypeScript, since they apparently keep changing their APIs, rendering so many past examples from gists and other posts close to useless. At the moment, I would like to make work with TypeScript and SolidJS the canonical force graph example. I feel like trying to solve a jigsaw puzzle since a lot of the types just won't match. The one I've had the most trouble with was the drag() arguments, I believe. I've also tried simply ignoring types, of course, but I couldn't make it work either. Also, does anyone know if it is possible to append any arbitrary component as a graph node? --- References 1. D3 - Force Directed Graph 1. Easily show relationships — Draw Simple Force Graph with React & d3 utilizing TypeScript 1. Building D3 interactive network graph D3 Force-Simulation + React + TypeScript 1. mbostock's Gist 1. steveharoz's Gist with Full Controls
10 replies