Android暂停并恢复上传

Android暂停并恢复上传,android,file-upload,Android,File Upload,我想为我的上传组件创建一个暂停和恢复系统。到目前为止,我能够使用以下代码直接、连续地将视频上传到ym remote server: private void uploadVideo(String videoPath) throws Exception { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(SEVER_ENDPOINT); FileBody f

我想为我的上传组件创建一个暂停和恢复系统。到目前为止,我能够使用以下代码直接、连续地将视频上传到ym remote server:

private void uploadVideo(String videoPath) throws Exception
{
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(SEVER_ENDPOINT);

    FileBody filebodyVideo = new FileBody(new File(videoPath));
    StringBody title = new StringBody("Filename: " + videoPath);
    StringBody description = new StringBody("Short description");

    MultipartEntity reqEntity = new MultipartEntity();
    reqEntity.addPart("videoFile", filebodyVideo);
    reqEntity.addPart("title", title);
    reqEntity.addPart("description", description);
    httppost.setEntity(reqEntity);

    if (DEBUG) Log.d(TAG, "executing request " + httppost.getRequestLine());
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity resEntity = response.getEntity();

    if (DEBUG) Log.d(TAG, response.getStatusLine());
    if (resEntity != null)
    {
        if (DEBUG) Log.d(TAG, EntityUtils.toString(resEntity));
        resEntity.consumeContent();
    }
    httpclient.getConnectionManager().shutdown();
}
我怎样才能暂停上传,保存进度。做任何我想做的事情(比如关闭应用程序),然后当我重新启动它时,恢复它并继续上传丢失的部分


感谢您的宝贵帮助。

我终于找到了实现这一目标的方法,从Github转到
Kienco


下面是他的代码链接:

首先,您需要检查您的服务器是否有用于此类可恢复上传的API。如果是,你应该使用这个API来做你想做的事情,如果不是,没有任何东西可以帮助你。嗨,马尼托巴省,这个解决方案是适用于任何服务器还是仅限于amazon s3?我想用不同的服务器api在我的应用程序中实现这个暂停/恢复上传。它应该适用于任何地方。只是别忘了在服务器上实现它。如果你使用
PHP
,你可以这样做:嘿,你能详细描述一下在我的服务器上实现什么吗,有没有我需要从amazon使用的服务(免费或付费)?我有我客户的服务器API和我的android代码。我想从android上实现暂停/恢复文件上传功能,所以如果我使用这个库,那么什么是访问密钥、存储桶密钥或密码等。这是亚马逊上注册需要的东西吗?你能给我指出正确的方向吗?我也在为同样的问题寻找解决方案。我不能用php实现AmazonS3服务器端代码。如果有人来解释客户端和服务器实现的所有内容(如果android+nodejs很好),这将帮助像我这样的初学者