Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

http_fetch with image upload

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Re: http_fetch with image upload

    Is there still any 401 errors when you try.

    Comment


      #17
      Re: http_fetch with image upload

      No, I get a 200 which is good, and the file is there. But it's no longer a useful image -- any jpg or .png I upload is no longer an image - just unusable.
      -Steve
      sigpic

      Comment


        #18
        Re: http_fetch with image upload

        In your example you use an image.
        I am sure you understand my previous posts but just to make sure

        Code:
        f = file.to_blob("C:\A5Webroot\Hoff_3.jpg")
        f = base64encode(f)

        or


        Code:
        f = file.to_blob("C:\A5Webroot\Hoff_3.jpg")
        f = base64encode_file(f)

        In both cases f is corrupt/not valid syntax at least in my tests. I am not able to convert f back to image (I do not use alpha to convert it back). Make sure that your f is valid. Edit: Base64encode is totally wrong, there is some = in begin of file and base64encode_file adds line breaks which do not belong there.
        Last edited by kkfin; 09-27-2018, 12:29 PM.

        Comment


          #19
          Re: http_fetch with image upload

          Thanks for sticking with this Ken. But that's my point. I know that what I'm doing is not correct -- it produces a file on the server that is not an image.

          So the question is: what is correct? How do I do this?
          -Steve
          sigpic

          Comment


            #20
            Re: http_fetch with image upload

            Better move to .Net.
            This code seems to produce right format at least with images I tested


            Code:
            save_to_file(system::Convert::ToBase64String(system::io::file::ReadAllBytes("C:\A5Webroot\Hoff_3.jpg")),"C:\A5Webroot\proper64.txt")

            Comment


              #21
              Re: http_fetch with image upload

              Kenneth - you seem to be saying that base64encode() in Xbasic does not match what .Net produces. If you have a reproducible case of this, please send us a bug report with the files that will cause this condition. In my testing, base64encode() creates exactly what .Net creates:
              Code:
              dim imgfn as c = "C:\dev\Lenny-Forziati.jpg"
              dim xb64 as c = base64encode(file.to_blob(imgfn))
              dim net64 as c = system::Convert::ToBase64String(file.to_blob(imgfn))
              
              ?xb64 == net64
              = .T
              Steve - you should carefully examine exactly what is sent by a browser on a successful upload with what is sent by http_fetch() that does not work. I still suspect that your POST body is not in the format that is expected/required by Google.

              Lenny Forziati
              Vice President, Internet Products and Technical Services
              Alpha Software Corporation

              Comment


                #22
                Re: http_fetch with image upload

                Since you got back past the authorization issue, have you tried the PUT method again?
                If using POST, are you sure the object has been removed before posting(creating) it again?
                And it isn't clear how you are determining the content-length after doing the f = base64encode(fb)


                EDIT: Or try to get rid of Content-Length header and replace it with this: Transfer-Encoding: chunked

                EDIT 2: Now I'm thinking that you shouldn't POST a base64encoded string to Google. Keep it as a blob as you had in your original message. of course make sure you have the updated headers concerning ssl that you didn't originally have as far as I could see.
                If the blob route still doesn't work, I suppose you could try to add the base64 prefix to the string if it isn't already (which I imagine it isn't). Then on the Google side you could decode it. Or perhaps with the prefix present, if you redownloaded it, the client browser would decode it(?)
                Still think I would prefer using the "Transfer-Encoding: chunked" but maybe you could use the blob.size() function to set the Content-length
                Last edited by jgrannis; 09-28-2018, 05:41 PM.

                Comment


                  #23
                  Re: http_fetch with image upload

                  By the way now Facebook did prove how dangerous OAuth 2.0 really and in fact hole concept is. Little mistakes in code (yes just Facebook but sure no other) and we do not need id or key to get access token for others data. And when we get one we get all others.

                  Comment


                    #24
                    Re: http_fetch with image upload

                    Thanks some more. I've tried another 100 iterations and combinations and read through several hundred StackOverflow threads based on my search.

                    Transfer-Encoding: chunked seems to be a sure way to generate a "bad request".

                    PUT generates a 404.

                    I tried to buy support from Alpha on this but cannot get support for a 3rd party API.

                    And I cannot even figure out where to buy support for the Google API.

                    My biggest customer is increasingly unhappy about this. It should be a simple upload to Google storage. But apparently it's not.
                    -Steve
                    sigpic

                    Comment


                      #25
                      Re: http_fetch with image upload

                      Ok, so 400 "bad request" seems normal if the server is pretty much insisting on a correct Content-length so that it can determine the end of the HTTP request.
                      Did you try going back to not using Transfer-Encoding: chunked and instead using Content-length with the result of blob.size()?

                      Comment


                        #26
                        Re: http_fetch with image upload

                        Is Nodejs yet an option?. There seems to be some npm alternatives to use. So basically you just have to pass xbasic filename variable to nodeservice(few lines of javascript) which starts then the actual Nodejs App. In Nodejs App you can directly use code what you find from web.

                        Comment


                          #27
                          Re: http_fetch with image upload

                          Originally posted by jgrannis View Post
                          Ok, so 400 "bad request" seems normal if the server is pretty much insisting on a correct Content-length so that it can determine the end of the HTTP request.
                          Did you try going back to not using Transfer-Encoding: chunked and instead using Content-length with the result of blob.size()?
                          Please read the Lennys post #5 There is no need to use Content-Length.

                          Comment


                            #28
                            Re: http_fetch with image upload

                            Ah, yes. I missed the end that said "If you simply omit that header, http_fetch() will automatically calculate the correct value for you."
                            I had read it meaning that it it should be calculated dynamically after the encoding.

                            Great. Then maybe the server is missing some information about the content encoding and need to add the header:
                            Content-Transfer-Encoding: BASE64

                            EDIT: seems like to documentation for http_fetch should indicate "If you simply omit that header, http_fetch() will automatically calculate the correct value for you." because normally we are allowed to add headers and it is not abnormal to omit Content-length and replace it with Transfer-Encoding: chunked. So it seems that if only Transfer-Encoding: chunked is added and Content-length is omitted but then automatically added and then we send both headers, the server can consider it an improperly formed request.
                            Last edited by jgrannis; 10-01-2018, 04:03 PM.

                            Comment


                              #29
                              Re: http_fetch with image upload

                              I think I had not realized at all that http_fetch might be Alpha Software's implement of the "Fetch standard".
                              If so, and I now imagine it is, there might be quite a bit of reading to do at the link below to understand Fetch...

                              https://fetch.spec.whatwg.org/

                              Seems like which headers are allowed and which are not is explained there ...although not very easy to understand.

                              Comment


                                #30
                                Re: http_fetch with image upload

                                Originally posted by jgrannis View Post
                                I think I had not realized at all that http_fetch might be Alpha Software's implement of the "Fetch standard".
                                If so, and I now imagine it is, there might be quite a bit of reading to do at the link below to understand Fetch...

                                https://fetch.spec.whatwg.org/

                                Seems like which headers are allowed and which are not is explained there ...although not very easy to understand.
                                The Xbasic http_fetch() function predates the "Fetch standard" by about a decade and is in no way intended to an implementation of that document.

                                Lenny Forziati
                                Vice President, Internet Products and Technical Services
                                Alpha Software Corporation

                                Comment

                                Working...
                                X