Loading ...
Sorry, an error occurred while loading the content.

Sending an image using JSON

Expand Messages
  • farkmischer
    I am trying to figure out how to send an image from my hard drive to Tuzulo using their api which appears to use JSON (quoted below). I have figured out how
    Message 1 of 11 , Mar 8, 2010
    • 0 Attachment
      I am trying to figure out how to send an image from my hard drive to Tuzulo using their api which appears to use JSON (quoted below). I have figured out how to receive information about what images I have with them and their URLs but cannot figure out how to send an image. I have found lots of JSON examples but they all seem to show sending or receiving strings. Could someone give me a hint?

      Quoted From:
      http://www.tuzulo.com/info/api

      Quote
      Private API URLsThese URLs require private keys, used for management and extension. To protect each upload, the private key must be known (saved, bookmarked, etc.). With an account, this becomes transparent.

      http://www.tuzulo.com/add/<private-key>

      Extend collection.

      http://www.tuzulo.com/upload/<private-key>

      Manage collection.

      Public keys are meant to be shared while private keys are meant to be temporarily bookmarked if necessary. Bookmarking is unnecessary when you're a site member.
      End Quote
    • Michael Schøler
      Hi, The only thing that pops to my mind is base64 encoding. JSON is not a suited container for binary data (see http://www.json.org/
      Message 2 of 11 , Mar 8, 2010
      • 0 Attachment
        Hi,



        The only thing that pops to my mind is base64 encoding. JSON is not a suited
        container for binary data (see <http://www.json.org/> http://www.json.org/
        for a complete reference). So find a string serialization for your image
        data, or use another way of transporting the data. The obvious JSON
        representation of an image would be e.g.:



        var jsonImage = { “url”: “http://somewhere/image.png”) };



        Best regards

        Michael



        From: json@yahoogroups.com [mailto:json@yahoogroups.com] On Behalf Of
        farkmischer
        Sent: 8. marts 2010 19:37
        To: json@yahoogroups.com
        Subject: [json] Sending an image using JSON





        I am trying to figure out how to send an image from my hard drive to Tuzulo
        using their api which appears to use JSON (quoted below). I have figured out
        how to receive information about what images I have with them and their URLs
        but cannot figure out how to send an image. I have found lots of JSON
        examples but they all seem to show sending or receiving strings. Could
        someone give me a hint?

        Quoted From:
        http://www.tuzulo.com/info/api

        Quote
        Private API URLsThese URLs require private keys, used for management and
        extension. To protect each upload, the private key must be known (saved,
        bookmarked, etc.). With an account, this becomes transparent.

        http://www.tuzulo.com/add/<private-key>

        Extend collection.

        http://www.tuzulo.com/upload/<private-key>

        Manage collection.

        Public keys are meant to be shared while private keys are meant to be
        temporarily bookmarked if necessary. Bookmarking is unnecessary when you're
        a site member.
        End Quote





        [Non-text portions of this message have been removed]
      • Fredag_d13
        To store binary data in a json string, you could use base64 or something similar. However it is more likely, that you should just post your binary data to the
        Message 3 of 11 , Mar 8, 2010
        • 0 Attachment
          To store binary data in a json string, you could use base64 or something similar. However it is more likely, that you should just post your binary data to the server without putting it into a json object.

          --- In json@yahoogroups.com, "farkmischer" <farkmischer@...> wrote:
          >
          > I am trying to figure out how to send an image from my hard drive to Tuzulo using their api which appears to use JSON (quoted below). I have figured out how to receive information about what images I have with them and their URLs but cannot figure out how to send an image. I have found lots of JSON examples but they all seem to show sending or receiving strings. Could someone give me a hint?
          >
          > Quoted From:
          > http://www.tuzulo.com/info/api
          >
          > Quote
          > Private API URLsThese URLs require private keys, used for management and extension. To protect each upload, the private key must be known (saved, bookmarked, etc.). With an account, this becomes transparent.
          >
          > http://www.tuzulo.com/add/<private-key>
          >
          > Extend collection.
          >
          > http://www.tuzulo.com/upload/<private-key>
          >
          > Manage collection.
          >
          > Public keys are meant to be shared while private keys are meant to be temporarily bookmarked if necessary. Bookmarking is unnecessary when you're a site member.
          > End Quote
          >
        • Mark Joseph
          Or you could use another encoding that was designed to handle binary data, and that is ASN.1 with BER or DER encoding. Best, Mark Joseph, Ph.D. President P6R,
          Message 4 of 11 , Mar 8, 2010
          • 0 Attachment
            Or you could use another encoding that was designed to handle binary data, and that is ASN.1
            with BER or DER encoding.


            Best,

            Mark Joseph, Ph.D.
            President
            P6R, Inc
            408-205-0361
            mark@...
            Skype: markjoseph_sc
            _____

            From: Fredag_d13 [mailto:jonas@...]
            To: json@yahoogroups.com
            Sent: Mon, 08 Mar 2010 13:33:02 -0800
            Subject: [json] Re: Sending an image using JSON






            To store binary data in a json string, you could use base64 or something similar. However it is more likely, that you should just post your binary data to the server without putting it into a json object.

            --- In json@yahoogroups.com, "farkmischer" <farkmischer@...> wrote:
            >
            > I am trying to figure out how to send an image from my hard drive to Tuzulo using their api which appears to use JSON (quoted below). I have figured out how to receive information about what images I have with them and their URLs but cannot figure out how to send an image. I have found lots of JSON examples but they all seem to show sending or receiving strings. Could someone give me a hint?
            >
            > Quoted From:
            > http://www.tuzulo.com/info/api
            >
            > Quote
            > Private API URLsThese URLs require private keys, used for management and extension. To protect each upload, the private key must be known (saved, bookmarked, etc.). With an account, this becomes transparent.
            >
            > http://www.tuzulo.com/add/<private-key>
            >
            > Extend collection.
            >
            > http://www.tuzulo.com/upload/<private-key>
            >
            > Manage collection.
            >
            > Public keys are meant to be shared while private keys are meant to be temporarily bookmarked if necessary. Bookmarking is unnecessary when you're a site member.
            > End Quote
            >




            [Non-text portions of this message have been removed]
          • Jacob Davies
            It s going to depend on the API, though I assume that most sites are going to want you to send the data via the multipart/form-data encoding that is used for
            Message 5 of 11 , Mar 8, 2010
            • 0 Attachment
              It's going to depend on the API, though I assume that most sites are
              going to want you to send the data via the multipart/form-data
              encoding that is used for browser file uploads, and if they require
              JSON in the request, probably want you store the entire JSON string in
              another form field in the same request.

              Alternatively as someone suggested they may want you to POST the
              binary data directly.

              Base-64 encoding binary data and storing it in a JSON string works
              fine of course (couldn't really not work!) but introduces a
              significant encoding overhead that makes it unsuitable for large
              network file transfers, so I doubt that's what they're doing.

              But only their documentation can tell you what they're actually expecting.


              On Mon, Mar 8, 2010 at 10:37 AM, farkmischer <farkmischer@...> wrote:
              > I am trying to figure out how to send an image from my hard drive to Tuzulo using their api which appears to use JSON (quoted below).  I have figured out how to receive information about what images I have with them and their URLs but cannot figure out how to send an image.  I have found lots of JSON examples but they all seem to show sending or receiving strings.  Could someone give me a hint?
              >
              > Quoted From:
              > http://www.tuzulo.com/info/api
              >
              > Quote
              > Private API URLsThese URLs require private keys, used for management and extension. To protect each upload, the private key must be known (saved, bookmarked, etc.). With an account, this becomes transparent.
              >
              > http://www.tuzulo.com/add/<private-key>
              >
              > Extend collection.
              >
              > http://www.tuzulo.com/upload/<private-key>
              >
              > Manage collection.
              >
              > Public keys are meant to be shared while private keys are meant to be temporarily bookmarked if necessary. Bookmarking is unnecessary when you're a site member.
              > End Quote
              >
              >
              >
              > ------------------------------------
              >
              > Yahoo! Groups Links
              >
              >
              >
              >



              --
              jacob@...
            • Dennis Gearon
              I personally set my API up using out of band uploading. Direct POSTing of the image (multipart encoding), and then put the url of the image resource in the
              Message 6 of 11 , Mar 8, 2010
              • 0 Attachment
                I personally set my API up using 'out of band' uploading. Direct POSTing of the image (multipart encoding), and then put the url of the image resource in the JSON for the next part of the request.

                It requires the Mobile device, to do some things in the background, or on a browser, use XMLHttpRequest, or multiple pages to do the full transaction.

                One of the advantages is that you can use Amazon or other cloud servers as yoru storage . . . or the local hard drive. All you have to do is change the prefix upto the directory/filename of the URL in the JSON, (assuming you keep all filenames the same, just change their location)

                Dennis Gearon



                Signature Warning

                ----------------

                EARTH has a Right To Life,

                otherwise we all die.



                Read 'Hot, Flat, and Crowded'

                Laugh at http://www.yert.com/film.php

                --- On Mon, 3/8/10, Jacob Davies <jacob@...> wrote:

                From: Jacob Davies <jacob@...>
                Subject: Re: [json] Sending an image using JSON
                To: json@yahoogroups.com
                Date: Monday, March 8, 2010, 6:48 PM







                 









                It's going to depend on the API, though I assume that most sites are

                going to want you to send the data via the multipart/form- data

                encoding that is used for browser file uploads, and if they require

                JSON in the request, probably want you store the entire JSON string in

                another form field in the same request.



                Alternatively as someone suggested they may want you to POST the

                binary data directly.



                Base-64 encoding binary data and storing it in a JSON string works

                fine of course (couldn't really not work!) but introduces a

                significant encoding overhead that makes it unsuitable for large

                network file transfers, so I doubt that's what they're doing.



                But only their documentation can tell you what they're actually expecting.



                On Mon, Mar 8, 2010 at 10:37 AM, farkmischer <farkmischer@ yahoo.com> wrote:

                > I am trying to figure out how to send an image from my hard drive to Tuzulo using their api which appears to use JSON (quoted below).  I have figured out how to receive information about what images I have with them and their URLs but cannot figure out how to send an image.  I have found lots of JSON examples but they all seem to show sending or receiving strings.  Could someone give me a hint?

                >

                > Quoted From:

                > http://www.tuzulo com/info/ api

                >

                > Quote

                > Private API URLsThese URLs require private keys, used for management and extension. To protect each upload, the private key must be known (saved, bookmarked, etc.). With an account, this becomes transparent.

                >

                > http://www.tuzulo com/add/<private-key>

                >

                > Extend collection.

                >

                > http://www.tuzulo com/upload/<private-key>

                >

                > Manage collection.

                >

                > Public keys are meant to be shared while private keys are meant to be temporarily bookmarked if necessary. Bookmarking is unnecessary when you're a site member.

                > End Quote

                >

                >

                >

                > ------------ --------- --------- ------

                >

                > Yahoo! Groups Links

                >

                >

                >

                >



                --

                jacob@...




















                [Non-text portions of this message have been removed]
              • Tatu Saloranta
                ... This really depends on implementation: at least fast java encoders can do with about same overhead as space expansion causes (33%). While higher relative
                Message 7 of 11 , Mar 8, 2010
                • 0 Attachment
                  On Mon, Mar 8, 2010 at 6:48 PM, Jacob Davies <jacob@...> wrote:
                  > It's going to depend on the API, though I assume that most sites are
                  > going to want you to send the data via the multipart/form-data
                  > encoding that is used for browser file uploads, and if they require
                  > JSON in the request, probably want you store the entire JSON string in
                  > another form field in the same request.
                  >
                  > Alternatively as someone suggested they may want you to POST the
                  > binary data directly.
                  >
                  > Base-64 encoding binary data and storing it in a JSON string works
                  > fine of course (couldn't really not work!) but introduces a
                  > significant encoding overhead that makes it unsuitable for large
                  > network file transfers, so I doubt that's what they're doing.

                  This really depends on implementation: at least fast java encoders can
                  do with about same overhead as space expansion causes (33%). While
                  higher relative overhead, it is not necessarily very significant for
                  many use cases, esp. if cpu is not the bottleneck. There is not
                  necessarily need to store intermediate encoded result in its entirety
                  either (and especially not as String); although some implementations
                  do that for simplicity.

                  Basically, this is one of those cases where not-so-good can be just
                  good enough, even for quite sizable binary data. Why do it that way?
                  It may be simplest way to do it, being able to bundle data, metadata,
                  multiple images all in a single message.

                  -+ Tatu +-
                • Jorge Chamorro
                  ... The browser can upload a local file to a server via a form through a POST, but your page s javascript code can t touch nor read a local file at all, at
                  Message 8 of 11 , Mar 9, 2010
                  • 0 Attachment
                    On 08/03/2010, at 19:37, farkmischer wrote:
                    > I am trying to figure out how to send an image from my hard drive to Tuzulo using their api which appears to use JSON (quoted below). I have figured out how to receive information about what images I have with them and their URLs but cannot figure out how to send an image. I have found lots of JSON examples but they all seem to show sending or receiving strings. Could someone give me a hint?
                    >
                    > Quoted From:
                    > http://www.tuzulo.com/info/api
                    >
                    > Quote
                    > Private API URLsThese URLs require private keys, used for management and extension. To protect each upload, the private key must be known (saved, bookmarked, etc.). With an account, this becomes transparent.
                    >
                    > http://www.tuzulo.com/add/<private-key>
                    >
                    > Extend collection.
                    >
                    > http://www.tuzulo.com/upload/<private-key>
                    >
                    > Manage collection.
                    >
                    > Public keys are meant to be shared while private keys are meant to be temporarily bookmarked if necessary. Bookmarking is unnecessary when you're a site member.
                    > End Quote
                    >

                    The browser can upload a local file to a server via a form through a POST, but your page's javascript code can't touch nor read a local file at all, at least not if the location.href is anything other than file:/// (e.g., not in a page that's coming from http://tuzulo.com).
                    --
                    Jorge.

                    [Non-text portions of this message have been removed]
                  • farkmischer
                    In response to a couple of quesitons I am using ASP.Net to do this so I do have access to the filesystem. Over the last few days I have determined in .net how
                    Message 9 of 11 , Mar 9, 2010
                    • 0 Attachment
                      In response to a couple of quesitons I am using ASP.Net to do this so I do have access to the filesystem. Over the last few days I have determined in .net how to format in image in Base64 and send the string to a URL (see below). However this still does not work. I get a "The remote server returned an error: (403) Forbidden." error. I believe that I am not formating what I am sending to tuzulo properly but am not sure what the string should look like. I also tried uploading the image directly without encoding it in Base64 like this client.UploadFile("http://tuzulo.com/add/***private key***", imgPhoto) but that did not work either. I'm not sure how to find out how to format my send, there does not seem to be a lot of information out there on this.

                      CODE:
                      System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile("c:\\test.jpg");
                      string ImageBase64 = ImageToBase64(imgPhoto, System.Drawing.Imaging.ImageFormat.Jpeg);

                      using (WebClient client = new WebClient())
                      {
                      return client.UploadString("http://tuzulo.com/add/***private key***", ImageBase64);
                      }
                      CODE:

                      --- In json@yahoogroups.com, "farkmischer" <farkmischer@...> wrote:
                      >
                      > I am trying to figure out how to send an image from my hard drive to Tuzulo using their api which appears to use JSON (quoted below). I have figured out how to receive information about what images I have with them and their URLs but cannot figure out how to send an image. I have found lots of JSON examples but they all seem to show sending or receiving strings. Could someone give me a hint?
                      >
                      > Quoted From:
                      > http://www.tuzulo.com/info/api
                      >
                      > Quote
                      > Private API URLsThese URLs require private keys, used for management and extension. To protect each upload, the private key must be known (saved, bookmarked, etc.). With an account, this becomes transparent.
                      >
                      > http://www.tuzulo.com/add/<private-key>
                      >
                      > Extend collection.
                      >
                      > http://www.tuzulo.com/upload/<private-key>
                      >
                      > Manage collection.
                      >
                      > Public keys are meant to be shared while private keys are meant to be temporarily bookmarked if necessary. Bookmarking is unnecessary when you're a site member.
                      > End Quote
                      >
                    • Josh Sled
                      ... You should ask tuzulo.com about how to use their API. This isn t a tuzulo.com support forum, and your question is only tangentially related to json. --
                      Message 10 of 11 , Mar 10, 2010
                      • 0 Attachment
                        "farkmischer" <farkmischer@...> writes:

                        > client.UploadFile("http://tuzulo.com/add/***private key***", imgPhoto) but that did not work either. I'm not sure how
                        > to find out how to format my send, there does not seem to be a lot of information out there on this.

                        You should ask tuzulo.com about how to use their API. This isn't a
                        tuzulo.com support forum, and your question is only tangentially related
                        to json.

                        --
                        ...jsled
                        http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo ${a}@${b}
                      • farkmischer
                        I apologize, you are right. I started out not even knowing how to use JSON so that is why I started here. Now that I figured out how to use JSON in .net I
                        Message 11 of 11 , Mar 10, 2010
                        • 0 Attachment
                          I apologize, you are right. I started out not even knowing how to use JSON so that is why I started here. Now that I figured out how to use JSON in .net I will contact tuzulo. They have a support forum that doesn't let you post to so I'll have to figure out how to contact them.

                          --- In json@yahoogroups.com, Josh Sled <jsled@...> wrote:
                          >
                          > "farkmischer" <farkmischer@...> writes:
                          >
                          > > client.UploadFile("http://tuzulo.com/add/***private key***", imgPhoto) but that did not work either. I'm not sure how
                          > > to find out how to format my send, there does not seem to be a lot of information out there on this.
                          >
                          > You should ask tuzulo.com about how to use their API. This isn't a
                          > tuzulo.com support forum, and your question is only tangentially related
                          > to json.
                          >
                          > --
                          > ...jsled
                          > http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo ${a}@${b}
                          >
                        Your message has been successfully submitted and would be delivered to recipients shortly.