ajayshukla / imageshackapi

Automatically exported from code.google.com/p/imageshackapi
0 stars 0 forks source link

base64 support for fileupload multipart #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a multipart/form-data request
2. Set the mimepart according to the specification
3. Set the Content-Transfer-Encoding: base64
4. Post the data in base64 format

What is the expected output? What do you see instead?
The expected output will be something different than a blank page

What version of the product are you using? On what operating system?
Using google chrome the http://www.imageshack.us/upload_api.php url

Please provide any additional information below.

below the javascript method to create the xhr request with a base64 data. The 
dataUrl param comes from canvas.toDataUrl('image/jpeg') or 
canvas.toDataUrl('image/png')

var xhr = new XMLHttpRequest();
        var boundaryString = '------------------------------'; 
        xhr.open('POST','http://www.imageshack.us/upload_api.php');
        //xhr.open('POST','http://localhost:8080/Upload/');
        xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary="+boundaryString);
        xhr.onreadystatechange = function()
        {
            if (xhr.readyState == 4) {
                if ((xhr.status >= 200 && xhr.status <= 200) || xhr.status == 304) {
                    if (xhr.responseText != "") {
                        alert(xhr.responseText); // display response.
                    }
                }
            };
        }
        dataUrl = dataUrl.substr(dataUrl.indexOf("base64,",0)+7);

        var cr = "\r\n"; 
        var boundary = "--"+ boundaryString;
        var body = boundary + cr;
        body+="Content-Disposition: form-data; name=\"key\""+cr+cr;
        body+="key"+cr;
        body+=boundary+cr;
        body+="Content-Disposition: form-data; name=\"fileupload\"; filename=\"gprFoto.jpeg\""+cr;
        body+="Content-Type: image/jpeg"+cr;
        body+="Content-Transfer-Encoding: base64"+cr+cr
        body+=dataUrl+ cr;
        body+=boundary+"--"+cr;
        xhr.send(body);

Original issue reported on code.google.com by atave...@gmail.com on 23 Jan 2011 at 3:46

GoogleCodeExporter commented 8 years ago
I am a android developer .I want image upload by the  ImageshackApi for android 
apps.Is it possible.If it  possible please send to me the sample code

Original comment by prosanto...@gmail.com on 7 Dec 2012 at 1:53