can t load an image from the springboot backend

gives the name but not much more than that
309 Replies
JavaBot
JavaBot•6mo ago
āŒ› This post has been reserved for your question.
Hey @Timo! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
\
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
dont you need like the whole path to the server to be added to the image
Timo
TimoOP•6mo ago
don t think so everything work even the image tag it just doesn t wanna load
ayylmao123xdd
ayylmao123xdd•6mo ago
yea but you are returning the image path and that path is on the server right so the client kinda needs the full path if im understanding it correctly wait let me check
Timo
TimoOP•6mo ago
it is local function getImageUrl(imagePath) { if (typeof imagePath === 'string') { if (imagePath.startsWith('http')) { return imagePath } return imagePath.startsWith('/') ? imagePath : /${imagePath} } }
Dexter
Dexter•6mo ago
export async function getAllEvents() {
try {
const response = await api.get('/events')
return response.data
} catch (error) {
console.error('Error fetching events:', error)
throw error
}
}
export async function getAllEvents() {
try {
const response = await api.get('/events')
return response.data
} catch (error) {
console.error('Error fetching events:', error)
throw error
}
}
This message has been formatted automatically. You can disable this using /preferences.
ayylmao123xdd
ayylmao123xdd•6mo ago
what are you using for the frontend tho
Timo
TimoOP•6mo ago
webapp
ayylmao123xdd
ayylmao123xdd•6mo ago
try to return the server url it should work then localhost:8080/ etc
Timo
TimoOP•6mo ago
don t know what you mean want to keep the images on the backend db
ayylmao123xdd
ayylmao123xdd•6mo ago
whats your server url localhost:8080 or something different
Timo
TimoOP•6mo ago
this?
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
so its 8081 ok so type in your browser localhost:8081/static.images/Westerpark.avif see if it shows you the image
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
so what are you using for frontend thymeleaf or something
Timo
TimoOP•6mo ago
vue
ayylmao123xdd
ayylmao123xdd•6mo ago
so local host 8081 is your web app host and whats the backend host
Timo
TimoOP•6mo ago
8080 i think
ayylmao123xdd
ayylmao123xdd•6mo ago
localhost:8080/static.images/Westerpark.avif try this then
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
oops my bad made a typo localhost:8080/static/images/WesterPark.avif try this
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
hmmmm ok try this localhost:8080/images/WesterPark.avif if that doesnt work show your application properties
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
yea show whats inside properties
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
lol comment out these last 2 lines you added and try the last url i sent
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
well thats quite interesting
Timo
TimoOP•6mo ago
:boohoo:
ayylmao123xdd
ayylmao123xdd•6mo ago
wait can you show you named this static.images folder is it 2 folders or 1 folder named weirdly
Timo
TimoOP•6mo ago
2 i think
Timo
TimoOP•6mo ago
\
No description
Timo
TimoOP•6mo ago
this is the folder made 2 but it used a .
ayylmao123xdd
ayylmao123xdd•6mo ago
let me check something hold on so i think you have something that blocks the access to static resources can you show your security config or something like that
Timo
TimoOP•6mo ago
ayylmao123xdd
ayylmao123xdd•6mo ago
for testing purposes can you add permit all for now on any request and try this url once again
Timo
TimoOP•6mo ago
prefer not to do that guess i will ask my senior dev friend tonight
ayylmao123xdd
ayylmao123xdd•6mo ago
oh its a real project
Timo
TimoOP•6mo ago
just a uni project
ayylmao123xdd
ayylmao123xdd•6mo ago
ok then here
public static final String[] PUBLIC_URL_PATTERNS = {
"/registrations/**",
"/events/**",
"/login",
"/home",
"/auth/**",
"/event",
"/api/registrations/**",
"/api/events/**",
"/error",
"/static/**",
"/images/**",
};
public static final String[] PUBLIC_URL_PATTERNS = {
"/registrations/**",
"/events/**",
"/login",
"/home",
"/auth/**",
"/event",
"/api/registrations/**",
"/api/events/**",
"/error",
"/static/**",
"/images/**",
};
try these patterns launch the app and try the url
Timo
TimoOP•6mo ago
ok sure doesn t work
ayylmao123xdd
ayylmao123xdd•6mo ago
wtf
Timo
TimoOP•6mo ago
lol you know what you are doing?šŸ˜…
ayylmao123xdd
ayylmao123xdd•6mo ago
of course this gif says i do
ayylmao123xdd
ayylmao123xdd•6mo ago
hmmmmmmmm @Timo did you try it out before did it work
Timo
TimoOP•6mo ago
noop
ayylmao123xdd
ayylmao123xdd•6mo ago
lol @Timo round 3 localhost:8080/api/images/WesterPark.avif try that
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
good call
ayylmao123xdd
ayylmao123xdd•6mo ago
see progress 😱
Timo
TimoOP•6mo ago
but what does thbis tell me :thonk: the image worked fine on the frontend same image so it isn t the image fault
ayylmao123xdd
ayylmao123xdd•6mo ago
means apache is acting weird
Timo
TimoOP•6mo ago
ugh any idea how to fix this?
ayylmao123xdd
ayylmao123xdd•6mo ago
of course but first i have to search for it
Timo
TimoOP•6mo ago
what info could we use to get there?
ayylmao123xdd
ayylmao123xdd•6mo ago
.authorizeHttpRequests((auth) -> auth
.requestMatchers(PUBLIC_URL_PATTERNS).permitAll()
.requestMatchers("/error").anonymous()
.anyRequest().authenticated()
)
.authorizeHttpRequests((auth) -> auth
.requestMatchers(PUBLIC_URL_PATTERNS).permitAll()
.requestMatchers("/error").anonymous()
.anyRequest().authenticated()
)
can you check what happens if you do any request permitall localhost:8080/api/images/WesterPark.avif localhost:8080/images/WesterPark.avif and then these urls
Timo
TimoOP•6mo ago
have that alr?
No description
Timo
TimoOP•6mo ago
server.servlet.context-path=/api you need the api infront
ayylmao123xdd
ayylmao123xdd•6mo ago
no i meant 1 second try .anyRequest().permitAll() just for testing purposes and try all these urls to the image
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
illegal
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
comment out this one
Timo
TimoOP•6mo ago
i hate spring security lol same as before it needs api and with a pi it doesn t work api
ayylmao123xdd
ayylmao123xdd•6mo ago
you get this without /api yes
Timo
TimoOP•6mo ago
yep
ayylmao123xdd
ayylmao123xdd•6mo ago
1 second its time for another crazy idea btw its static/images not static.images
Timo
TimoOP•6mo ago
doesn t matter tho still doesn t show up lol
ayylmao123xdd
ayylmao123xdd•6mo ago
yea i know i was just saying ok lets ask some sigmas cuz im too lazy to search for it @dan1st can u check doesnt show image when typing the url for the resource
dan1st
dan1st•6mo ago
ahhhh pings on Eclipse release day
ayylmao123xdd
ayylmao123xdd•6mo ago
next time set a do not disturb status :GnuTrolling:
dan1st
dan1st•6mo ago
it's fine
ayylmao123xdd
ayylmao123xdd•6mo ago
anyway problem is when typing url to the image like
dan1st
dan1st•6mo ago
So it's a 404?
ayylmao123xdd
ayylmao123xdd•6mo ago
ye
dan1st
dan1st•6mo ago
Where is the image located?
ayylmao123xdd
ayylmao123xdd•6mo ago
resources/static/images
dan1st
dan1st•6mo ago
like where is it stored? ok
ayylmao123xdd
ayylmao123xdd•6mo ago
and throws no static resource
dan1st
dan1st•6mo ago
that doesn't look like static/images but rather resources/static.images
No description
dan1st
dan1st•6mo ago
Was that checked before? Can I see the application.properties?
ayylmao123xdd
ayylmao123xdd•6mo ago
thats how intellij clips folders if im correct here
dan1st
dan1st•6mo ago
I thought it had some indicator maybe
dan1st
dan1st•6mo ago
ok
No description
dan1st
dan1st•6mo ago
What is the exact URL?
ayylmao123xdd
ayylmao123xdd•6mo ago
it would be localhost:8080/api/images/WesterPark.avif for example
dan1st
dan1st•6mo ago
ok
ayylmao123xdd
ayylmao123xdd•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
and it throws this
ayylmao123xdd
ayylmao123xdd•6mo ago
otherwise throws this
No description
Timo
TimoOP•6mo ago
uh nu uhh
dan1st
dan1st•6mo ago
Can I see the content of the resources folder in the file explorer? @Timo
Timo
TimoOP•6mo ago
no i can t see the avif file
dan1st
dan1st•6mo ago
ehhh yeah lmao
Timo
TimoOP•6mo ago
but it did work in the frontend too
ayylmao123xdd
ayylmao123xdd•6mo ago
u sure u didnt name the folder static.images right
dan1st
dan1st•6mo ago
I managed to sneak into the New and Noteworthy entry in today's Eclipse release lol
Timo
TimoOP•6mo ago
No description
dan1st
dan1st•6mo ago
Can you show in the file explorer?
Timo
TimoOP•6mo ago
what about lol
dan1st
dan1st•6mo ago
Outside of IntellIj
ayylmao123xdd
ayylmao123xdd•6mo ago
did you create 2 folders static and images or did you create 1 folder static.images
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
oh
dan1st
dan1st•6mo ago
ok
ayylmao123xdd
ayylmao123xdd•6mo ago
so the correct path
dan1st
dan1st•6mo ago
Can I see the compiled files? In the build folder Probably build/main or something like that
Timo
TimoOP•6mo ago
don t see that using gradle if that matters
dan1st
dan1st•6mo ago
Can you check outside of IntelliJ? that's why the folder should be named build and not target If it was Maven, I would know it's in target/classes/images
Timo
TimoOP•6mo ago
No description
dan1st
dan1st•6mo ago
What's in main?
ayylmao123xdd
ayylmao123xdd•6mo ago
oh no gradle šŸ™€
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
no thats src check in backend ntr website folder
dan1st
dan1st•6mo ago
oh right
ayylmao123xdd
ayylmao123xdd•6mo ago
what you got in there
Timo
TimoOP•6mo ago
No description
dan1st
dan1st•6mo ago
What's in classes? if there's a main folder, go in there as well
Timo
TimoOP•6mo ago
No description
dan1st
dan1st•6mo ago
Can you show the content of the resources folder?
ayylmao123xdd
ayylmao123xdd•6mo ago
i think it should be build/classes/static/images
dan1st
dan1st•6mo ago
build/resources/static/images I think idk Gradle stuff by heart
ayylmao123xdd
ayylmao123xdd•6mo ago
i never used it so im guessing lmao
dan1st
dan1st•6mo ago
I think with Maven, it would be target/classes/static/images
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
im from the maven gang
dan1st
dan1st•6mo ago
sounds about right
Timo
TimoOP•6mo ago
kotlin uses gradle as default
dan1st
dan1st•6mo ago
Can you stop the application and run it via gradlew bootRun?
Timo
TimoOP•6mo ago
what the hell is gradlew bootrun/
dan1st
dan1st•6mo ago
In IntelliJ, press the Ctrl key twice and in the input dialog, enter gradlew bootRun
Timo
TimoOP•6mo ago
No description
dan1st
dan1st•6mo ago
I think that should do something yep there
Timo
TimoOP•6mo ago
why does it have the w
ayylmao123xdd
ayylmao123xdd•6mo ago
from helping intellij users so often ur gonna be an expert of it without ever opening intellij
dan1st
dan1st•6mo ago
Typically gradle uses a wrapper script - e.g. the gradlew.bat this wrapper script finds the right Gradle version or downloads it if necessary
Timo
TimoOP•6mo ago
bootrun is slow lol
dan1st
dan1st•6mo ago
tbh I don't like these but they work most of the time even if you don't have Gradle installed
Timo
TimoOP•6mo ago
hella slow lol
No description
dan1st
dan1st•6mo ago
Can you open the website again?
Timo
TimoOP•6mo ago
frontend backend?
dan1st
dan1st•6mo ago
it sais started
No description
dan1st
dan1st•6mo ago
the one you tried to access before where the image doesn't work
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
how long should a bootrun take?
dan1st
dan1st•6mo ago
until you stop it As soon as it says "Started", it's started and then it runs until you stop it Can you try the image?
Timo
TimoOP•6mo ago
so same as running the backend but with some perks
dan1st
dan1st•6mo ago
the one that didn't work before
Timo
TimoOP•6mo ago
wdym it should show up if it worked?
dan1st
dan1st•6mo ago
yes it's the same thing but it's run by Gradle properly ideally but we'll see
Timo
TimoOP•6mo ago
so what do you expect me to do?
dan1st
dan1st•6mo ago
show me what happens when requesting the image again when running it via gradlew bootRun
Timo
TimoOP•6mo ago
but what tasks does that involce?
dan1st
dan1st•6mo ago
makes sure the project is built properly
Timo
TimoOP•6mo ago
but how should i check that
dan1st
dan1st•6mo ago
omg
dan1st
dan1st•6mo ago
No description
dan1st
dan1st•6mo ago
you have this in your application.properties comment out the spring.web.resources.static-locations line
Timo
TimoOP•6mo ago
\
No description
Timo
TimoOP•6mo ago
did that restarted no images on the frontend yet
dan1st
dan1st•6mo ago
same request again?
Timo
TimoOP•6mo ago
same way but this with that commented out
dan1st
dan1st•6mo ago
Can you show it? and you restarted the backend?
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
No description
dan1st
dan1st•6mo ago
Can you show the request to the specific image from before?
Timo
TimoOP•6mo ago
what do you mean with from before?
Dexter
Dexter•6mo ago
No description
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
😱 shocking
Timo
TimoOP•6mo ago
need to change the config for that ig 1 min
ayylmao123xdd
ayylmao123xdd•6mo ago
so what was the problem target not built properly
Dexter
Dexter•6mo ago
No description
dan1st
dan1st•6mo ago
application.properties
ayylmao123xdd
ayylmao123xdd•6mo ago
oh well at first i thought to comment it out cuz it should search that on default
dan1st
dan1st•6mo ago
it's /static.images there, not /static
Timo
TimoOP•6mo ago
🤩
No description
Timo
TimoOP•6mo ago
so what should be the problem with the db to frontend?
ayylmao123xdd
ayylmao123xdd•6mo ago
your controller should return the url you typed to the resource so it shows up
Timo
TimoOP•6mo ago
No description
dan1st
dan1st•6mo ago
What exactly is the problem there?
Timo
TimoOP•6mo ago
i simply just want it from the db im a bit confused
No description
Timo
TimoOP•6mo ago
that the images don t show up in the frontend
dan1st
dan1st•6mo ago
Can you check the browser devtools?
Timo
TimoOP•6mo ago
No description
dan1st
dan1st•6mo ago
Seems like it requests the wrong URLs?
Timo
TimoOP•6mo ago
but how should it get it then cuz it is better to load from the db than for the images in the backend? the rest just gets loaded out of the db so yeah does that makes sense cuz from the db is better right?
ayylmao123xdd
ayylmao123xdd•6mo ago
you need to send the whole image path so localhost:8080/api/images/WesterPark.avif thats the request the frontend needs to send to load that image
Timo
TimoOP•6mo ago
but then i don t use the db like i do for the rest
ayylmao123xdd
ayylmao123xdd•6mo ago
wdym in yoru dto when you fetch from db you can just add the uhhhhhhhhhhh localhost:8080 so if in your databsae you got '/static/images/blabla/ in dto add localhost:8080 does that make sense
Timo
TimoOP•6mo ago
noo guess my brain is fried uh
ayylmao123xdd
ayylmao123xdd•6mo ago
lmao ok in simpler words
ayylmao123xdd
ayylmao123xdd•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
you have this in your database show how your dto looks like and fetching from database
Dexter
Dexter•6mo ago
package com.example.backend.dto;
public class EventDTO {
}
public class EventDTO {
}
This message has been formatted automatically. You can disable this using /preferences.
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
wait where is the code where you fetch the event from the database is it this one
Timo
TimoOP•6mo ago
the eventservice yeah
ayylmao123xdd
ayylmao123xdd•6mo ago
oh its the get all okay so if you dont want to add dto what you need to do is in the image field do actually nevermind you gotta use dto anyway lol orrrr not
Timo
TimoOP•6mo ago
:thonk:
ayylmao123xdd
ayylmao123xdd•6mo ago
change /static/images/WesterPark.avif to /images/WesterPark.avif and on your frontend show your frontend
Dexter
Dexter•6mo ago
public List<Event> getAll() {
return eventRepository.findAll();
}
}
public List<Event> getAll() {
return eventRepository.findAll();
}
}
This message has been formatted automatically. You can disable this using /preferences.
ayylmao123xdd
ayylmao123xdd•6mo ago
no frontend
Dexter
Dexter•6mo ago
export async function getAllEvents() {
try {
const response = await api.get('/events')
return response.data
} catch (error) {
console.error('Error fetching events:', error)
throw error
}
}
export async function getAllEvents() {
try {
const response = await api.get('/events')
return response.data
} catch (error) {
console.error('Error fetching events:', error)
throw error
}
}
This message has been formatted automatically. You can disable this using /preferences.
ayylmao123xdd
ayylmao123xdd•6mo ago
the web app great
Timo
TimoOP•6mo ago
yeah i know chill
ayylmao123xdd
ayylmao123xdd•6mo ago
im mega chill
ayylmao123xdd
ayylmao123xdd•6mo ago
i have this pillow btw lmao
Timo
TimoOP•6mo ago
function getImageUrl(imagePath) { if (typeof imagePath === 'string') { if (imagePath.startsWith('http')) { return imagePath } return imagePath.startsWith('/') ? imagePath : /${imagePath} } }
ayylmao123xdd
ayylmao123xdd•6mo ago
anyway
Timo
TimoOP•6mo ago
i like that smile
ayylmao123xdd
ayylmao123xdd•6mo ago
okay so just do 'localhost:8080/api' + imagePath when you are showing the image
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
like this?
ayylmao123xdd
ayylmao123xdd•6mo ago
return 'localhost:8080/api' + imagePath
return 'localhost:8080/api' + imagePath
idk the correct javascript syntax but yea
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
show how you set the image link img src
Timo
TimoOP•6mo ago
in code or in webtools?
ayylmao123xdd
ayylmao123xdd•6mo ago
code show the code where you set stuff basically
Timo
TimoOP•6mo ago
<img :src="getImageUrl(event.image)" :alt="event.title" />
ayylmao123xdd
ayylmao123xdd•6mo ago
can you try hardcoding it for a second
<img :src="url to image here" :alt="event.title" />
<img :src="url to image here" :alt="event.title" />
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
no i meant
<img :src="localhost:8080/api/images/WesterPark.avif" :alt="event.title" />
<img :src="localhost:8080/api/images/WesterPark.avif" :alt="event.title" />
check if that works
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
fixed it
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
ok so
Timo
TimoOP•6mo ago
next challenge is let it use the local db :idontunderstand:
ayylmao123xdd
ayylmao123xdd•6mo ago
now add the old method get image url with this return check if it works
Timo
TimoOP•6mo ago
why would it work now?
ayylmao123xdd
ayylmao123xdd•6mo ago
if (typeof imagePath === 'string') {
if (imagePath.startsWith('http')) {
return imagePath
}
if (typeof imagePath === 'string') {
if (imagePath.startsWith('http')) {
return imagePath
}
do you even need this part why not just do
function getImageUrl(imagePath) {
return 'http://localhost:8080/api' + imagePath
}
function getImageUrl(imagePath) {
return 'http://localhost:8080/api' + imagePath
}
Timo
TimoOP•6mo ago
fair <img :src="getImageUrl(event.image)" :alt="event.title" />
ayylmao123xdd
ayylmao123xdd•6mo ago
yes and the method i sent
Dexter
Dexter•6mo ago
function getImageUrl(imagePath) {
return 'localhost:8080/api' + imagePath
}
function getImageUrl(imagePath) {
return 'localhost:8080/api' + imagePath
}
This message has been formatted automatically. You can disable this using /preferences.
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
u forgot the http that i added
Dexter
Dexter•6mo ago
function getImageUrl(imagePath) {
return 'http://localhost:8080/api' + imagePath
}
function getImageUrl(imagePath) {
return 'http://localhost:8080/api' + imagePath
}
This message has been formatted automatically. You can disable this using /preferences.
ayylmao123xdd
ayylmao123xdd•6mo ago
si
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
show whats in the database
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
the path to image
Timo
TimoOP•6mo ago
how can i see that?
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
oooh well that explains a lot i would say its better to return the path only so just make another field in the database with like named like imagePath or something and put the path there
Timo
TimoOP•6mo ago
but why 2? that is confusing
ayylmao123xdd
ayylmao123xdd•6mo ago
because what you are storing is byte and not a string that is the actual path what that means is you are returning the whole image to the frontend instead of just the url which is not that efficient
Timo
TimoOP•6mo ago
is a blob better then?
ayylmao123xdd
ayylmao123xdd•6mo ago
no what i meant is add another field in your database named imagePath and put the path there make it a string unless you wanna do it how it currently is sooooooo ur choice but sending only the path is more efficient
Timo
TimoOP•6mo ago
but what is the point of the db then if im storing it doible im confused
ayylmao123xdd
ayylmao123xdd•6mo ago
rn you are getting the actual image bytes from the database and sending it to the client
Timo
TimoOP•6mo ago
yeah so why doesn t that work?
ayylmao123xdd
ayylmao123xdd•6mo ago
show the response on the events endpoint what it returns on the image field
Timo
TimoOP•6mo ago
from the frontend my brain has a stack overflow ngl
ayylmao123xdd
ayylmao123xdd•6mo ago
lmao yea on the frontend click inspect elements network events and response
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
wrong request
ayylmao123xdd
ayylmao123xdd•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
this one
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
yea and click response or whatever thats named in dutch or the language you are using
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
correct
ayylmao123xdd
ayylmao123xdd•6mo ago
expand the first json and show what it says on image
Timo
TimoOP•6mo ago
No description
ayylmao123xdd
ayylmao123xdd•6mo ago
alright now
Timo
TimoOP•6mo ago
šŸ‘€
ayylmao123xdd
ayylmao123xdd•6mo ago
function getImageUrl(imagePath) {
if (!imagePath) return '';
return `data:image/png;base64,${imagePath}`;
}
function getImageUrl(imagePath) {
if (!imagePath) return '';
return `data:image/png;base64,${imagePath}`;
}
try this
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
weird <img :src="getImageUrl(event.image)" :alt="event.title" /> why didn t it bring anything?
ayylmao123xdd
ayylmao123xdd•6mo ago
show the function
Timo
TimoOP•6mo ago
function getImageUrl(imagePath) { if (!imagePath) return ''; return data:image/avif;base64,${imagePath}; } first had png didn t work either
Dexter
Dexter•6mo ago
function getImageUrl(imagePath) {
return data:image/avif;base64,${imagePath};
}
function getImageUrl(imagePath) {
return data:image/avif;base64,${imagePath};
}
This message has been formatted automatically. You can disable this using /preferences.
ayylmao123xdd
ayylmao123xdd•6mo ago
try this
Timo
TimoOP•6mo ago
// function getImageUrl(imagePath) { // if (!imagePath) return ''; // return data:image/avif;base64,${imagePath}; // } function getImageUrl(imagePath) { return 'data:image/avif;base64,${imagePath}'; } like this without '' i get errors
Timo
TimoOP•6mo ago
No description
Timo
TimoOP•6mo ago
should we ask daniel?
dan1st
dan1st•6mo ago
hm? the 101 switching protocols thing is not an error - it's normal behavior for websockets (it switches from HTTP(s) to WS(s))
Timo
TimoOP•6mo ago
but why doesn t it wanna show it even with this
dan1st
dan1st•6mo ago
I think if it includes the base64, it should be the base64 of the image content, not the image path so either the server could send you the path of the image and then the client loads the image from that path or the server sends you the base64 of the image content
Timo
TimoOP•6mo ago
but what needs to be changed then cuz i sent the db content of the image? like i just don t know what to change at htis point
ayylmao123xdd
ayylmao123xdd•6mo ago
it already sends the byte[] let me check print each events image here while fetching it from database i think somethings wrong with this byte thing
Timo
TimoOP•6mo ago
i have to eat now will be back in 30 min or so šŸ˜… thank you for the help tho
JavaBot
JavaBot•6mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
ayylmao123xdd
ayylmao123xdd•6mo ago
ok
Timo
TimoOP•6mo ago
done use a b64 to convert it into the db otherwise it was not possible
ayylmao123xdd
ayylmao123xdd•6mo ago
so does it show the image now
Timo
TimoOP•6mo ago
yeah but prob wanna fix it another way cuz the b64 takes up 7000 lines in the data.sql
ayylmao123xdd
ayylmao123xdd•6mo ago
well thats how saving an image works l0l what you could is on app startup actually nvm waste of time
Timo
TimoOP•6mo ago
is is done alr can close this after infinite messages lol
dan1st
dan1st•6mo ago
your decision if you consider it done, feel free to close the post
Timo
TimoOP•6mo ago
what has that to do with this post?
JavaBot
JavaBot•6mo ago
Post Closed
This post has been closed by <@591288621345275915>.

Did you find this page helpful?