Custom Variables in the Upload process

Last post 06-27-2008 6:15 AM by mmania. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-26-2008 8:04 AM

    • mmania
    • Top 10 Contributor
    • Joined on 01-20-2008
    • Netherlands
    • Posts 83

    Custom Variables in the Upload process

     Hi all,

    not sure if there's an easier way or if I am totally on the wrong path, but this is what I could come up when looking at how to improve the current upload feature for my web application. This is linked to my previous post (http://developer.nirvanix.com/forums/t/314.aspx) around the ItemID.

    It would be very handy if we could pass some custom parameters during the upload call and these parameters could be forwarded to the callbackurl.

    Currently we can only upload the files to a specified directory and use the callbackurl to perform some operations (namely securing that the file is uploaded in the right directory), but the usage is limited.

    Let's imagine that I want to ask the user if the file he's uploading is public or private. Currently the user uploads the file, then goes back to the list of uploaded files, selects the file and sets file to public/private. Not really an optimal process...

    If we could add some custom parameters that will be appended to the callback URL we could do the upload and set the public/private flag in one single operation.

    So, if we defined a common rule where all variables corresponding do a standard naming convention (like "cust_myvariable"), and passed in the POST operation to upload.ashx, are also appended to the callbackurl, well, we could allow to perform several operations in the background process triggered by the callbackurl.

    The final process would then look like this:

       1. HTTP upload from browser containing custom variables
       2. Callback URL is called and custom variables appended. The callbackurl performs operations on the uplaoded file, based also on the custom variables. Db entry, set tags, categories, set private/public, etc
       3. forwardingURL shows success/failure page to user

    Just to give an idea I think the same could be applied to the forwardingURL, as in the upload form we could ask to the user "Upload file and go back to the list or continue with other uploads?". By using a custom variable appended to the forwardingURL we could then display the list of files or show again the upload form, depending on what the user decided.

    The bottom line is that we could make the upload process quicker, more flexible and interactive...

    hope it helps and feel free to shoot at it :-)

    ciao

    Luca

    Filed under: ,
  • 06-26-2008 5:32 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 519

    Re: Custom Variables in the Upload process

     This already exists in the form of appending variables to the callback URL you define.  I will setup a scenerio and give a solution to that scenerio so you can see how this can be accomplished.

    The Client Uploads (Pseudo code)

    CallbackURL = "http://myhost.com/mycallbackhandler.php?cust_myvariable=" + isImage + "&cust_myvariable2=" + myvalue2

    Nirvanix.UploadFile(filedata, filename, options, callbackURL)

    The Server Callback Handler, mycallbackhanlder.php on the myhost.com server 

    custVariable = RequestVarible["cust_myvariable"]

    custVariable2 = RequestVarible["cust_myvariable2"] 

    if (custVariable == isImage)

      Nirvanix.ImageResize(RequestVarible["filename"], outputfilename)

    end if

     

    The above scenerio passes two variables from an upload request to the server side handler that will then call image resize if the upload is marked isImage.

    I think this is a very common case, you can define just about any simple variable by appending the value to the callback URL you have defined.  We will echo back anything you have passed to us as well as the NVX.ResponseCode etc.  This is also true for the forwardingURL parameter.

    Regards,
        Barry R.

    IM Support (Feel free to add me)

    MSN: barryruffner@msn.com
    Gmail: barryruffner@gmail.com
  • 06-27-2008 6:15 AM In reply to

    • mmania
    • Top 10 Contributor
    • Joined on 01-20-2008
    • Netherlands
    • Posts 83

    Re: Custom Variables in the Upload process

     Thanks Barry...

    I just went back to you upload file example and indeed I could just simply use som javascript to dynamically set the callbackURL value depending on what the user enters in the form... 

    thanks a lot a for the example and the explanation!

    ciao

    Luca

Page 1 of 1 (3 items)