0

How to get server response using the uploader

Hi,

I tried to used the B+ using your uploader sample.

I could not get the server response after upload is done. Can anyone helps me on this?

This is the url of my sample page:
http://www.dumingag.com/browserplus/drag_drop2.html

Thanks.

by
19 Replies
  • QUOTE (stillman @ Jan 2 2009, 04:31 PM) <{POST_SNAPBACK}>
    Hi,

    I tried to used the B+ using your uploader sample.

    I could not get the server response after upload is done. Can anyone helps me on this?

    This is the url of my sample page:
    http://www.dumingag.com/browserplus/drag_drop2.html

    Thanks.

    What server response r u expecting ? I see a <span> with id 'fileProgress' and a <pre> with id 'serverResponse'. But where is the code which puts data into these elements ?
    0
  • QUOTE (stillman @ Jan 2 2009, 04:31 PM) <{POST_SNAPBACK}>
    Hi,

    I tried to used the B+ using your uploader sample.

    I could not get the server response after upload is done. Can anyone helps me on this?

    This is the url of my sample page:
    http://www.dumingag.com/browserplus/drag_drop2.html

    Thanks.


    Hi Stillman,

    At the very least we have a documentation bug here. The uploader service that the uploader tool wraps does provide body, and I see from tcpdump that your php script is returning a valid body with some diagnostic information.

    This documentation will be updated to cover the return values:
    http://browserplus.yahoo.com/developer/services/?s=uploader

    And I will poke steve (the guy who wrote the uploader) to ask him whether we're providing a hook to get at the response body through the uploader js wrapper.

    If the answer is no, perhaps we could patch the JS and get you to test an updated version for us. this would get you a new uploader in the short term that you could use, and then we could incorporate the new api into our next site push.

    Steve, what say you?

    Stillman, hows this sound?

    best,
    lloyd
    0
  • The response body was not included in the fileCB data. I made a small change that should fix the problem. The javascript for the modified uploader.js is located here:

    http://hackthebrowser.org/u/steve/js/uploader_1.0.3-min.js

    The response data is stored in a new "value" field in the callback result object:

    CODE
    var fileCallback = function(res) {
    if (res.success && res.action === "uploaded") {
    // dump_json(res.value);
    }
    };


    a JSON.Stringify dump of above:

    CODE
    {
    "statusCode":200,
    "statusString":"200 OK",
    "headers":
    {
    "Connection":"close",
    "Content-Type":"text/html",
    "Date":"Mon 05 Jan 2009 23:21:57 GMT",
    "Server":"Apache/1.3.41 (Darwin) PHP/5.2.6",
    "Transfer-Encoding":"Identity",
    "X-Powered-By":"PHP/5.2.6"
    },
    "body":"Upload Recieved"
    }


    Let me know if this works for you. If so, we'll get the documentation updated and the javascript uploaded to our site.

    Cheers,

    Steve
    0
  • QUOTE (steven_spencer @ Jan 5 2009, 03:54 PM) <{POST_SNAPBACK}>
    The response body was not included in the fileCB data. I made a small change that should fix the problem. The javascript for the modified uploader.js is located here:

    http://hackthebrowser.org/u/steve/js/uploader_1.0.3-min.js

    The response data is stored in a new "value" field in the callback result object:

    CODE
    var fileCallback = function(res) {
    if (res.success && res.action === "uploaded") {
    // dump_json(res.value);
    }
    };


    a JSON.Stringify dump of above:

    CODE
    {
    "statusCode":200,
    "statusString":"200 OK",
    "headers":
    {
    "Connection":"close",
    "Content-Type":"text/html",
    "Date":"Mon 05 Jan 2009 23:21:57 GMT",
    "Server":"Apache/1.3.41 (Darwin) PHP/5.2.6",
    "Transfer-Encoding":"Identity",
    "X-Powered-By":"PHP/5.2.6"
    },
    "body":"Upload Recieved"
    }


    Let me know if this works for you. If so, we'll get the documentation updated and the javascript uploaded to our site.

    Cheers,

    Steve




    Steve,

    I used your modified uploader.js and it works! I can get now the server response of each file uploaded as you can see if you try my test link above.

    One more thing though....

    Is there a way that we can determine if all the files in that particular batch of upload has been uploaded? Coz I want to have a script/module run whenever it receives a trigger that all files on the batch has been finished uploading.

    Hope am clear enough on this for you to understand what I mean.

    Thanks,

    Stillman
    0
  • QUOTE (stillman @ Jan 7 2009, 01:46 AM) <{POST_SNAPBACK}>
    Steve,

    I used your modified uploader.js and it works! I can get now the server response of each file uploaded as you can see if you try my test link above.

    One more thing though....

    Is there a way that we can determine if all the files in that particular batch of upload has been uploaded? Coz I want to have a script/module run whenever it receives a trigger that all files on the batch has been finished uploading.

    Hope am clear enough on this for you to understand what I mean.

    Thanks,

    Stillman


    Right now, that can't be determined with the Uploader tool. I will look into creating an event for that.

    If you use the raw Uploader service directly, there is a way to pass in multiple files at once so it'd be easy to tell when all files have been uploaded. Think the difference is that your server side code would have to handle a multipart upload.

    Cheers,

    Steve
    0
  • QUOTE (steven_spencer @ Jan 7 2009, 04:21 PM) <{POST_SNAPBACK}>
    Right now, that can't be determined with the Uploader tool. I will look into creating an event for that.

    If you use the raw Uploader service directly, there is a way to pass in multiple files at once so it'd be easy to tell when all files have been uploaded. Think the difference is that your server side code would have to handle a multipart upload.

    Cheers,

    Steve


    Ok. Hope you can create an event for that.

    Lastly, can we set the maximum filesize of each file and the maximum number of files per batch of upload on the present Uploader tool? If not, can you add them? I think it's a very useful feature.

    Thanks,


    Stillman
    0
  • QUOTE (stillman @ Jan 7 2009, 04:40 PM) <{POST_SNAPBACK}>
    Ok. Hope you can create an event for that.

    Lastly, can we set the maximum filesize of each file and the maximum number of files per batch of upload on the present Uploader tool? If not, can you add them? I think it's a very useful feature.

    Thanks,


    Stillman


    http://hackthebrowser.org/u/steve/js/uploader_1.0.5.js
    http://hackthebrowser.org/u/steve/js/uploader_1.0.5-min.js

    Two new callbacks added, uploadCompleteCB and constraintCB.

    uploadCompleteCB is called after all files in the list have been uploaded.

    CODE
    function uploadCompleteCB(res) {
    if (res.success) { /* good */ }
    }


    constraintCB is called if there's a constraint violation: (1) too many files, (2) file too big (3) wrong mime type selected

    CODE
    function constraintCB(res) {
    /* res contains:
    constraint - one of "toobig" "toomany" "mime"
    name - file name
    size - file size
    mimetype - mime type
    */
    }


    To register these events and set constraints:

    CODE
    var uploader = BPTool.Uploader.create("mediumDiv", 
    {
    uploadCompleteCB: mycb.uploadCompleteCB,
    constraintCB: mycb.constraintCB,
    maxFiles: 5,
    maxFileSize: 100000, /* size in bytes */
    mimeTypes: ["application/pdf"]
    });


    --steve
    0
  • QUOTE (steven_spencer @ Jan 13 2009, 03:54 PM) <{POST_SNAPBACK}>
    http://hackthebrowser.org/u/steve/js/uploader_1.0.5.js
    http://hackthebrowser.org/u/steve/js/uploader_1.0.5-min.js

    Two new callbacks added, uploadCompleteCB and constraintCB.

    uploadCompleteCB is called after all files in the list have been uploaded.

    CODE
    function uploadCompleteCB(res) {
    if (res.success) { /* good */ }
    }


    constraintCB is called if there's a constraint violation: (1) too many files, (2) file too big (3) wrong mime type selected

    CODE
    function constraintCB(res) {
    /* res contains:
    constraint - one of "toobig" "toomany" "mime"
    name - file name
    size - file size
    mimetype - mime type
    */
    }


    To register these events and set constraints:

    CODE
    var uploader = BPTool.Uploader.create("mediumDiv", 
    {
    uploadCompleteCB: mycb.uploadCompleteCB,
    constraintCB: mycb.constraintCB,
    maxFiles: 5,
    maxFileSize: 100000, /* size in bytes */
    mimeTypes: ["application/pdf"]
    });


    --steve


    Steve,

    One thing I notice is that the mimeType of each file returned as "undefined" instead of the correct type.

    Other than that, it works perfectly.

    Thanks,


    Stillman
    0
  • QUOTE (stillman @ Jan 14 2009, 03:25 PM) <{POST_SNAPBACK}>
    Steve,

    One thing I notice is that the mimeType of each file returned as "undefined" instead of the correct type.

    Other than that, it works perfectly.

    Thanks,


    Stillman


    I just fixed a bug in the underlying uploader service that caused it to not add the correct "Content-Type:" header to the uploaded files. As a result, your server would have seen something like "application/octet-stream" instead of something like "image/jpeg". We'll be pushing the fixed uploader service fairly soon.

    -- gordon
    0
  • QUOTE (Gordon @ Jan 15 2009, 02:57 PM) <{POST_SNAPBACK}>
    I just fixed a bug in the underlying uploader service that caused it to not add the correct "Content-Type:" header to the uploaded files. As a result, your server would have seen something like "application/octet-stream" instead of something like "image/jpeg". We'll be pushing the fixed uploader service fairly soon.

    -- gordon



    Thanks. Will be waiting for the modified uploader to be pushed to the server.

    Cheers,


    Stillman
    0
  • QUOTE (stillman @ Jan 15 2009, 03:42 PM) <{POST_SNAPBACK}>
    Thanks. Will be waiting for the modified uploader to be pushed to the server.

    Cheers,


    Stillman


    Hey Stillman,

    Uploader 3.1.7 is now available which should have correct content type headers, give it a look and holler back with your results.

    very best,
    lloyd
    0
  • QUOTE (Lloyd Hilaiel @ Jan 28 2009, 09:00 PM) <{POST_SNAPBACK}>
    Hey Stillman,

    Uploader 3.1.7 is now available which should have correct content type headers, give it a look and holler back with your results.

    very best,
    lloyd


    Lloyd,

    Where can I find Uploader 3.1.7? Let me know the location of the file.

    All I can find is Uploader 1.0.4 here http://browserplus.yahoo.com/developer/web/toolbox/upload/ which still gives an incorrect content type headers when we upload a jpeg file.

    Thanks,


    Aner
    0
  • QUOTE (stillman @ Jan 31 2009, 04:13 AM) <{POST_SNAPBACK}>
    Where can I find Uploader 3.1.7? Let me know the location of the file.


    Please ignore this.


    But still the uploader has a problem of the jpeg file.
    0
  • QUOTE (stillman @ Jan 31 2009, 04:22 AM) <{POST_SNAPBACK}>
    Please ignore this.


    But still the uploader has a problem of the jpeg file.


    Lloyd,

    You can check it out on this demo:
    http://browserplus.yahoo.com/developer/web...oad/colors.html

    It does not accept jpeg file although it was set to do so.

    Thanks,


    Stillman
    0
  • QUOTE (stillman @ Jan 31 2009, 04:26 AM) <{POST_SNAPBACK}>
    Lloyd,

    You can check it out on this demo:
    http://browserplus.yahoo.com/developer/web...oad/colors.html

    It does not accept jpeg file although it was set to do so.

    Thanks,


    Stillman


    In the colors.html demo, we misspelled "constraintCB" (left out of "s") when registering the callback. If you copy the code locally and fix this, you will see that "*.jpg" files are coming through with a mime type like: "image/jpeg,image/pjpeg".

    We will fix our demo. Thanks for finding this.

    Steve
    0
  • We updated the Uploader tool to version 1.0.5. This version fixes the problem with JPGs so you just have to specify ["image/jpeg"]. The "colors.html" has been updated on the site as well.

    Let us know if you still have problems with filtering.

    Thanks,

    Steve
    0
  • QUOTE (steven_spencer @ Feb 2 2009, 07:25 PM) <{POST_SNAPBACK}>
    We updated the Uploader tool to version 1.0.5. This version fixes the problem with JPGs so you just have to specify ["image/jpeg"]. The "colors.html" has been updated on the site as well.

    Let us know if you still have problems with filtering.

    Thanks,

    Steve



    Steve,

    Everything works perfectly now.

    Thanks,


    Stillman
    0
  • QUOTE (steven_spencer @ Feb 2 2009, 07:25 PM) <{POST_SNAPBACK}>
    We updated the Uploader tool to version 1.0.5. This version fixes the problem with JPGs so you just have to specify ["image/jpeg"]. The "colors.html" has been updated on the site as well.

    Let us know if you still have problems with filtering.

    Thanks,

    Steve


    Steve,

    There is a minor glitch with the current Uploader Tool. It is in the postCB (line 656 of the original code).

    This code:
    CODE
    postObj = ConfigParams.postCB(getUUID(droppedFiles[0]));



    Should be:
    CODE
    postObj = ConfigParams.postCB(getUUID(droppedFiles[i]));

    In order to retrieve extra data for each file.

    Other than that, the uploader works great.

    Thank,

    Stillman
    0
  • Thank you! I will fix that.

    Steve
    0
This forum is locked.

Recent Posts

in Support & General Questions