Hello. each user has an avatar. I have already made an avatar selection from the gallery and I can also take a photo. Then I need the user to see not only his avatar, but all the others. That is, I think, after choosing an avatar, you need to save this file to the server so that others can download this file via url. I know how to download via url, but how to write pictures to the server?

  • It all depends on the server. - Lucky_spirit
  • please explain what exactly? - Firespirit
  • @Firespirit on which server are you going to upload pictures? Check the documentation as it takes pictures. For example, I wrote an application on Android for VK and there it is clearly written in the documentation that the photo needs to be sent POST by request to a specific URL. Well, after that I already started to look, how in Android it is possible to transfer the picture POST by request. And at random to send somewhere the picture makes no sense. The server may not accept. Probably need pre-authorization. Once again I will write. It all depends on how the server is configured to receive pictures. - Lucky_spirit
  • I set up the server myself, I can do everything I want - Firespirit

1 answer 1

  1. Send by post-request and process on the server.
  2. By ftp
  • How to send a POST request for a picture? Is it possible then to write this into the database? Tipo make a text from a picture or what? - Firespirit
  • You send a post-request image as an array of bytes. There the direct method seems to have a bitmap toByteArray () - Suvitruf
  • And an array of bytes how to write to the database? I mean how to keep it? I just do not know in sql which type fits an array of bytes, I only know the text, varkar, integer, double, and how to store an array of bytes in sql? - Firespirit
  • @Suvitruf, it’s not very good to store pictures in the database, it’s better to store on disk and distribute directly, but to base the paths. - dzhioev
  • one
    @Firespirit, well, think about it yourself. I usually do not care how to store on the server. The picture itself can be stored with whatever (but unique) name, and in the database to make a bunch of this picture with the user. When adding a picture, make an entry in the database (get a unique identifier of the entry), and save the picture itself to disk with this unique identifier. - Suvitruf