-1

My question is quite simple but I can't find any clear reference : I'm building a webservice that returns gameboard informations (in json for unity) and the image of the game.

  • Should I, in my informations include a field "image" with my image in base64 ?
  • Or in my information include a field "image" with the exposed url of the image (on my server still), and then do a second call to get the image ?

Which is the best practice toward unity android/ios ?

lrosique
  • 113
  • 1
  • 9
  • https://stackoverflow.com/questions/39177576/how-to-to-return-an-image-with-web-api-get-method Already answered. – auslander Aug 08 '18 at 07:18
  • sorry but I don't see any justification, they are just using bytes* but it doesn't tell me why or if that's a good idea. Can you elaborate please ? – lrosique Aug 08 '18 at 07:21

2 Answers2

0

OK, i will prefer to use first option.Your information include image field.As http works with TCP it will deliver 100% and i think there is no need for second call to get game image

auslander
  • 470
  • 5
  • 17
  • but the image will be sent everytime i display gameboard informations. Won't it consume resources for nothing ? with url approach i can download image only if it's not in cache, right ? – lrosique Aug 08 '18 at 08:18
  • Yes , but i dont know your situation , what means cache? i thought your image every time will be different . If it is same all time or changing rarely you can choose your second option, download image with different call when you need or use your cache . Consume resources? you can overwrite old image with new one.If you about server and network resources 1 little image cannot affect performance as it is not intensive call . – auslander Aug 08 '18 at 09:02
0
  • In my experience, use the second method avoid downloading the same image every time when I call the webservice.
  • I just check the image if exist in persistent data directory of my device. Don't need to download the resource again until the url content changed.
siusiulala
  • 1,040
  • 1
  • 12
  • 24
  • yes, I wasn't going to download the image every time, that's why i hesitate between the two approaches : with base64, the image will be sent everytime. With url, i'll first check if i have the image before downloading it for display... So what would you do ? use url ? – lrosique Aug 08 '18 at 08:17
  • I choose the way of url – siusiulala Aug 08 '18 at 08:20