Using Google BlobStore with an Android application

前端 未结 2 1771
没有蜡笔的小新
没有蜡笔的小新 2020-12-22 00:40

I found 1 thread about this question, which did partially answer the question, but I\'m afraid I may need some details.

I\'m currently trying to use BlobStore with m

相关标签:
2条回答
  • 2020-12-22 01:03

    I used the following and it worked.

    This is an example if you post as gzip content:

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
        GZIPOutputStream gzos = null;
        try {
            gzos = new GZIPOutputStream(baos);
            gzos.write(xml.getBytes());
        } finally {
            if (gzos != null)
                try {
                    gzos.close();
                } catch (IOException ex) {
                }
        }
    
        byte[] fooGzippedBytes = baos.toByteArray();
        MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        entity.addPart("name", new ByteArrayBody(fooGzippedBytes,"application/x-gzip", "filename"));
    
        httpPost.setEntity(entity);
    
    0 讨论(0)
  • 2020-12-22 01:16

    Ok, after some search, here is the solution ;

    It seems that headers are not working as I expected, so I just deleted them.

    HttpPost httppost = new HttpPost(url);
    MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    entity.addPart("data", new ByteArrayBody(image,"image/jpeg","avatar.jpg"));
    httppost.setEntity(entity);
    response = httpClient.execute(httppost);
    processResponse(response);
    
    0 讨论(0)
提交回复
热议问题