wip
This commit is contained in:
@@ -9,21 +9,28 @@ export default function useInputImage() {
|
||||
headers.append("pragma", "no-cache")
|
||||
headers.append("cache-control", "no-cache")
|
||||
|
||||
fetch(`${API_ENDPOINT}/inputimage`, { headers }).then(async (res) => {
|
||||
const filename = res.headers
|
||||
.get("content-disposition")
|
||||
?.split("filename=")[1]
|
||||
.split(";")[0]
|
||||
fetch(`${API_ENDPOINT}/inputimage`, { headers })
|
||||
.then(async (res) => {
|
||||
if (!res.ok) {
|
||||
throw new Error("No input image found")
|
||||
}
|
||||
const filename = res.headers
|
||||
.get("content-disposition")
|
||||
?.split("filename=")[1]
|
||||
.split(";")[0]
|
||||
|
||||
const data = await res.blob()
|
||||
if (data && data.type.startsWith("image")) {
|
||||
const userInput = new File(
|
||||
[data],
|
||||
filename !== undefined ? filename : "inputImage"
|
||||
)
|
||||
setInputImage(userInput)
|
||||
}
|
||||
})
|
||||
const data = await res.blob()
|
||||
if (data && data.type.startsWith("image")) {
|
||||
const userInput = new File(
|
||||
[data],
|
||||
filename !== undefined ? filename : "inputImage"
|
||||
)
|
||||
setInputImage(userInput)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
}, [setInputImage])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user