我们如何将图像发送到Kotlin的服务器?
我尝试将我从当地画廊获得的图像发送到大招牌。图像所需的类型是字符串($二进制)。如何将其发送到服务器?我已经在Google和YouTube中进行了搜索,但是看来我仍然没有找到所需的教程,有时它比碎片在活动中。所以我感到困惑。我是科特林的新手。这是我的片段代码: https://codeshare.io/3amwy6 ,这是我的ViewModel代码: https://codeshare.io/lw0xnl 谢谢您的回答。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
推荐方法
如果将图像上传到服务器。您可以选择Multipartbody的类型。部分并进行改造,您可以在此教程简化编码中找到解决方案
android上传
文件
可以将图像转换为由位组成的位图,然后用此 library 由PixelCarrot撰写,或者您可以手动转换它
Recomended Method
If you are uploading image to server. You can choose type of MultipartBody.Part and sending with retrofit you can find your solution in this tutorial Simplified Coding
Android Upload File to Server
Requested Method
Firstly you can convert image to bitmap which is consist of bits then convert to string with this library written by pixelcarrot or you can convert it manually