简体   繁体   English

如何将图像从Android设备上传到Rails服务器?

[英]How to upload image from Android device to Rails server?

I am working on a Android project and want to upload Bitmap images to my rails server. 我正在开发一个Android项目,想将位图图像上传到我的Rails服务器。 But I have no idea how to write the Rails models or controllers. 但是我不知道如何编写Rails模型或控制器。

I find someone using MultipartEntity post to upload images and paperclip to recieve images on RoR server. 我发现有人使用MultipartEntity帖子上传图像,并使用回形针在RoR服务器上接收图像。 I want to know how to connect the post and server (what url?) and how to write the model or controller. 我想知道如何连接帖子和服务器(URL是什么?)以及如何编写模型或控制器。

I use a stupid method. 我使用愚蠢的方法。 I convert the Bitmap image to byte array and use Base64 method to convert it to a string. 我将位图图像转换为字节数组,并使用Base64方法将其转换为字符串。 Post the string to server. 将字符串发布到服务器。 When I want to get image, download the string and convert it to Bitmap. 当我想获取图像时,下载字符串并将其转换为Bitmap。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM