Hi Everyone,

I have been working tirelessly to complete a simple image upload to
the blob store from a blackberry client. As anyone that has coded
blackberry apps know, the API makes you wish iPhone and Android were
the only smartphone players.

I am using a httpConnection over a tcpIp connection and a multi-part
form to complete the upload. I am able to see the byte code in the
POST in the Blob_store handler on the server side. I am unable,
however, to access the file with get_uploads(). The entire uploads []
is empty. I've tried just about everything with the headers and
content-disposition etc. that I can think of or find online. Any help
would be greatly appreciated.The current client code is as follows:

String boundary = "AaThisisthecallasprinklz";
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE,
HttpProtocolConstants.CONTENT_TYPE_MULTIPART_FORM_DATA
+";boundary="+boundary);
Dialog.inform( "Header code junk "
+HttpProtocolConstants.CONTENT_TYPE_MULTIPART_FORM_DATA);
conn.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_LENGTH,String.valueOf(postData.length));
Dialog.inform( "Header content length="
+HttpProtocolConstants.HEADER_CONTENT_LENGTH);
ByteArrayOutputStream out1 = new ByteArrayOutputStream();

        OutputStream finalOut = conn.openOutputStream();



        String newLine = "\r\n";

        out1.write(newLine.getBytes());

        out1.write("--".getBytes());

        out1.write(boundary.getBytes());

        out1.write(newLine.getBytes());

        String contDisp="Content-Disposition: form-data;name=\"media
\";filename=\"/Device Memory/home/user/pictures/IMAGE200.bmp\"";

        String contEnc = "Content-Transfer-Encoding: binary";

        String type="Content-Type:image/bmp";

        out1.write(contDisp.getBytes());

        out1.write(newLine.getBytes());

        out1.write(type.getBytes());

        out1.write(newLine.getBytes());

        out1.write(contEnc.getBytes());

        out1.write(newLine.getBytes());

        out1.write(newLine.getBytes());

        out1.write(postData);

        out1.write(newLine.getBytes());

        out1.write("--".getBytes());

        out1.write(boundary.getBytes());

        out1.write("--".getBytes());

        out1.write(newLine.getBytes());

;
        finalOut.write(out1.toByteArray());



        out1.flush();

        out1.close();



        finalOut.flush();

        finalOut.close();

Server Side Code:

class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
    def post(self):
        logging.debug("in upload handler")
        upload_files = self.get_uploads()  # 'file' is file upload
field in the form
        logging.debug("the uploads are %s" %upload_files)
        logging.debug("post content = %s" %self.request.POST)

        logging.debug("total files in upload: %d" %len(upload_files))
        blob_info = upload_files[0]
        logging.debug("got image")
        thumb_key = str(blob_info.key())

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to