I'm using the spring boot gradient base.
I have a question. After I bring the path containing the image file from the database, I change the image file to byte and return it, but can you tell me how it is usually done? The way I did it, it returns to the byte value like this.
@RequestMapping (value="path", method=RequestedMethod.GET)
public JSONObject selectImage() throws Exception{
JSONObject obj=new JSONObject();
byte[] files=FileUtils.readFileToByteArray("path containing files");
obj.put("response",files);
return obj
}
Does it return like this? I got it with Postman and it was really long
AK1TQwaqykrHGGwMZBOP1rR2RB9wcn1qWMIUbaw+tHQLlFLPV5CMugx1wv8Aial/s3Uj96869go/wq/CUB+UZ9TUnmQ9x+OKA6FG30q85V71yO+DircWgkLl7mVl9C5q1bzRY5QY9SKmjuPNGwdKLAnYrx6JaMu6SINjgEinxaPbxZMcA69hVtbhQCoGQKdBcpyCpPPpQkx3O68Cx+T4Yto9uAAwx/wNq1Zm3KyZ7Cs/wkQPDNuR6P8A+htV0sQxOa3j8JyP4mMIJXb6Uu4pGVHfikJODj0peWhJ9+aETY8n+JkYXW3/AB/nXKeGxt8YxN2G3+Zrrfim6jWHI9647w45/wCEnjcnrj+ZpxNV8J7bp2JYQR6VowuvlNEfSszQDuiAb0rRkwhyPWjqZk1uoVCPakJwuwGiFgUJpjNgFqeokB27SM81XcZDCpG3GTg8VDMSjYNK2pQW4IUg/wCetOfhCR6UkakZPtTih2Gn0GV4yN+7NWd2I8CoVjC85p8bhwV9KkCMuSCDRAMZA9aHUqTmn248zn0qo7E7Ecw5P+fWhATH9Kkmj+c/59ajXcp20bAirIxYlR/nrT4lwtIYv3xPan8AUmURyrgZrM8ZhJPCV6rLn91kfnWizliVqn4khWXw1fI3RbR2z9ATR0A8rWJVNKxIHFKCD0NORARk0jQrOTz9OP1pkfU1LMoDEVCuUOTQtQLMEgVSuaWRfNGPyqKFd3NWI1wM/lRtsBEkW2nEZGM0O2CQP89aarHPJoTsGg0kA7TTiBjOaawJbj1pyDJp9AFVMrnP0p9up5/z600sBxUlsy5NLcFqP8ptuaRBk/Sp8gxnFQBwhP1oQIlkwYcVVk6ketW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6QceI4T9P50RNfsnt2guFiHNaxwyZrF0Fs2qHvxmtkjbEAKDLYfAv7s49KVVDKc0625gJH+etR7gsR+vNFxoGjAO4npVa5wWH1qd3wnFVJHzwTQtUKxKcKQPapkj3Q59qrFiSDnIxVy1w0RHtQt2WUHYqxXH+eadbId+6kmA8w/WpIPlUkdjR5AJc7ccHmo7OTaxB9adJk5xUceEbI9aIsnpYuPtZsGoHUBzUjZLA57UyXIJNPdAiEqAxNRTEhSVqRz8pJqMYYcUWHd3IIAzy8im63CJdEvLYHG+1kH5qRVmOMK+4UzUIWntJ4kGWaJlX6kGjQZ45Dkn61a2fJnFVolIYe1W/MGzHtU3NClcD56j2EjpU8yZOajBGSvpT6AOgXaCPQVPVfdt5BqWJyRg0rANlGCTTdvy7s0+YD1pE+5z/nrT3Aai7s5NPAAGBTVK5IHenouTz2oQEMitu4NS2ud2M+lDoCaWBdrHmgCfOBtzUcqYG4VIQCcmm53fLRpcVxbckDFOnUdQaFQqmaa5YilYZIq7Ys1C2CTVpVLWvHaqjDk/X/GkgGhMZwak2/IciiMjkelOZCENVYCIEN0NSryOtQAlSafvITINNLTQQp+/jNDHa2abG248+tPZc9KYyaJQ4waRTtcgUsZKCmbcyZBqLC3Q549+SB/nmmLHsP1NWE+VcEVHMcDNVshWVjsofGriAPD4Nu1dzhReTpGD75XdUE/jrVo/wB7H4YtNu7HzX7E59gI6ivp445DauiEKmAS5IJP8jUFrbBrkTpkxrjc4X7p9K71QppbHD7SY+/8b+IYLkpFBpwUEZSSKQlT3G4Ng/kKgTxf42vbiWA32nKqo
spring-boot image return
Is the code you just uploaded working properly? It's going to be a text transmission of binary data, so it doesn't
To transfer binary data, there is a way to use a file stream, not to respond with text. And the response header should be set appropriately so that the client knows that this transmission is binary data.
There are a lot of things that come out when you search for java spring file download or java file download.
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
917 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.