save useInputImage with correct filename
This commit is contained in:
@@ -8,11 +8,18 @@ export default function useInputImage() {
|
|||||||
headers.append('pragma', 'no-cache')
|
headers.append('pragma', 'no-cache')
|
||||||
headers.append('cache-control', 'no-cache')
|
headers.append('cache-control', 'no-cache')
|
||||||
|
|
||||||
fetch('/inputimage', { headers })
|
fetch('/inputimage', { headers }).then(async res => {
|
||||||
.then(res => res.blob())
|
const filename = res.headers
|
||||||
.then(data => {
|
.get('content-disposition')
|
||||||
|
?.split('filename=')[1]
|
||||||
|
.split(';')[0]
|
||||||
|
|
||||||
|
const data = await res.blob()
|
||||||
if (data && data.type.startsWith('image')) {
|
if (data && data.type.startsWith('image')) {
|
||||||
const userInput = new File([data], 'inputImage')
|
const userInput = new File(
|
||||||
|
[data],
|
||||||
|
filename !== undefined ? filename : 'inputImage'
|
||||||
|
)
|
||||||
setInputImage(userInput)
|
setInputImage(userInput)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user