在Android的发送图像和视频服务器图像、视频服务器、Android

2023-09-05 08:44:52 作者:投入太彻底

我创建一个Android应用程序用于拍摄照片和视频。拍摄图像后,我想送这个图像日期和一些文字到Web服务器。在服务器端,我做这个图片和视频的应用程序。拍摄的图像将被保存在存储卡中。使用JSON我如何发送图像文字。此外,我想送影片到Web服务器。

I am creating an android application for taking photos and videos. After capture images I want to send this image with date and some text to web server. In server side I am making an application with this pictures and videos. The image captured will be saved in memory card. How can I send image with text using JSON. Also I want to send Videos to the web server.

推荐答案

您可以做到这一点的,多部分职位要求:(这样,你不需要创建JSON)

You can do this with a Multipart post request:(This way, you dont need to create json)

        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost(serverURL);
        MultipartEntity postEntity = new MultipartEntity();
        File file = new File("Your File path on SD card");
        postEntity.addPart("fileupload", new FileBody(file, "image/jpeg"));
        postEntity.addPart("loginKey", new StringBody(""+loginKey));
        postEntity.addPart("message", new StringBody(message));
        postEntity.addPart("token", new StringBody(token));
        post.setEntity(postEntity);
        response = client.execute(post);

您必须添加此 mime4j 库。

 
精彩推荐
图片推荐