save useInputImage with correct filename
This commit is contained in:
parent
78d6b1cc3e
commit
2b031603ed
@ -8,14 +8,21 @@ export default function useInputImage() {
|
||||
headers.append('pragma', 'no-cache')
|
||||
headers.append('cache-control', 'no-cache')
|
||||
|
||||
fetch('/inputimage', { headers })
|
||||
.then(res => res.blob())
|
||||
.then(data => {
|
||||
if (data && data.type.startsWith('image')) {
|
||||
const userInput = new File([data], 'inputImage')
|
||||
setInputImage(userInput)
|
||||
}
|
||||
})
|
||||
fetch('/inputimage', { headers }).then(async res => {
|
||||
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)
|
||||
}
|
||||
})
|
||||
}, [setInputImage])
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user