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

Decode image path stored outside webroot?

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

    Decode image path stored outside webroot?

    I'm looking for some help on showing images.

    I have images stored in a data folder external the the webroot for my application. I want to display these images but I don't know how to decode them using xbasic to get them to show up in a web page. (The built-in image stuff is NOT available - custom data source on a list control)

    filename_decode gives me the absolute path on the server (eg, "C:/site/data/img.jpg") and not something that works for the src attribute for an image tag.

    Is there a method available that will do this for me? Do I need to copy the images to the session folder?
    Alpha Anywhere latest pre-release

    #2
    Re: Decode image path stored outside webroot?

    SO - I can use a5w_Decode_IFR.

    I'm wondering if I've been going about this all the wrong way. Maybe I should be using a flat dataset instead of a Nested JSON array. My data is in the form:

    Code:
    [
        {
            "parent_id": "xxx1",
            "img1": "img1.jpg",
            "img2": "img2.jpg",
            "CHILDREN": [
                {
                    "child_id": "yyy1",
                    "img1": "img1.jpg",
                    "img2": "img2.jpg"
                },
                {
                    "child_id": "yyy2",
                    "img1": "img1.jpg",
                    "img2": "img2.jpg"
                }
            ]
        },
        {
            "parent_id": "xxx2",
            "img1": "img1.jpg",
            "img2": "img2.jpg",
            "CHILDREN": []
        },
        {
            "parent_id": "xxx3",
            "img1": "img1.jpg",
            "img2": "img2.jpg",
            "CHILDREN": [
                {
                    "child_id": "yyy3",
                    "img1": "img1.jpg",
                    "img2": "img2.jpg"
                }
            ]
        }
    ]
    This is the data source for my List. I'm trying to get the img1.jpg, img2.jpg etc to display. They reside in directories external to the webroot.

    Unfortunately, because it contains arrays, it doesn't show any child fields in the list control - so I can't use the handy Image settings for image file reference fields for the children. :( Last I checked, Alpha knows about this issue but hasn't addressed it yet.
    Alpha Anywhere latest pre-release

    Comment


      #3
      Re: Decode image path stored outside webroot?

      I would like to know how to do this, too. But for me, I'm wanting to know how one would do this with other files besides images.

      I run my application with a load balancer and four instances of Alpha. Each instance apparently has to have its own root folder. This creates quite a problem when there is data that comes from disk files and not SQL.

      1) The first problem is with the disk files that Alpha uses for locking a user out of the system for failed login attempts. Alpha seems to store this in files and not SQL, even though everything else in the Web security is maintained in SQL, for my app!

      When a person gets locked out, Alpha records that in a text file located underneath the running instance. That instance has no idea that it should also update other running instances of Alpha. That means if the user trys again and lands on one of the other instances they will get some extra tries. That probly isn't too bad, as I don't give them many tries in the first place. The real hassle, though, is when the application administrator logs in and tries to view/update the lockout status of various users. The system only shows the status correctly for users that were locked out of the same instance of Alpha that the administrator is running on. Really makes it difficult to correctly see and change the lockouts.

      2) Another problem is that dynamically created .CSS files have to be duplicated across multiple instances. In my app, the application administrator creates a number of .CSS files that will be unique to their site. I'd really like to have these stored in a folder outside of the root, but I have not been able to get the LoadCSS command to work with absolute folder paths.

      IIS has "virtual" directories. I would like to see Alpha Web Server have these too.
      https://technet.microsoft.com/en-us/...(v=ws.10).aspx

      I have not solved problem (1) yet. I'm going to have to completely discard the login component that alpha made from a template and then create my own from scratch and implement my own user lockout. But, for problem (2) I added a table to the SQL database that lists the physical paths to the 4 instances of the application servers. When I need to save a dynamically created .CSS file, I loop through that table and duplicate the css file to subfolders of the listed instances.

      Comment


        #4
        Re: Decode image path stored outside webroot?

        Originally posted by RichCPT View Post
        . Each instance apparently has to have its own root folder.
        Is the problem url?
        If not url so what is the problem with same root and different subfolders for instances?

        Comment


          #5
          Re: Decode image path stored outside webroot?

          For me the problem is that I believe the "{grid.Object}.loadCSSFile(cssFileNm , true);" JavaScript command cannot instruct the application server to load a file that is located outside of its running instance. I think using absolute file paths and relative paths that try to going up one or more folder levels via "..\" are disallowed. Perhaps I am wrong about it having to be a relative path at or below the current instance path. I admit, I didn't spent a lot of time trying to workaround the issue because it is the same issue I had under a different web server environment. But, it makes sense to me that the server would prevent the client from requesting a file that is located outside of the running instance. But, as I think about this more I wonder if the server could process a Path Alias from the client in the loadCSSFile() function?

          http://wiki.alphasoftware.com/~alpha...String+Aliases

          Comment


            #6
            Re: Decode image path stored outside webroot?

            I believe you're not allowed to load a local resource. You can define a [Path.Alias] to point to your local folder, but that's not going to help on the web side. You could define your List data at the server level and, using a [Path.Alias] (if needed) or just straight code your path, and then base64encode your images to pass back to the client. Not sure where you're getting your List data from.

            Comment


              #7
              Re: Decode image path stored outside webroot?

              You can load external css file outside root using Node.
              In this example output is in .a5w page.
              You can use Node also in UX.

              File mycss.css is outside root in folder data in computer alpha in c drive

              Code:
              p{color : red;}
              This code is for exports.handler function. The file name is staticcss.js

              Code:
              var attachments = null;
              var fs = require('fs');
              fs.readFile( packet.myfile,'utf-8', function(error, data) {
              	if (error) {
              		console.log('MUM!!!');
              	}
              	else {
              		console.log(data);
              	}
                  response.result = 'Script ended';
                  response.css = data;
                  sendResponse(response, attachments);
               });
              This is output page and xbasic code to run node service. The html is just for testing purpose.

              Code:
              <%a5 
              newnode.myfile = "\\alpha\c$\data\mycss.css"
              dim nodejson as c
              nodejson = node_request("staticcss",newnode)
              dim p2 as p
              p2 = json_parse(nodejson)
              %>
              
              DOCTYPE html>
              <html>
              <style>
              <%a5 
              ? p2.css
              %>
              </style>
              <head>
              
              <title>Static css</title>
              </head>
              <body>
              <p>Red</p>
              </body></html>
              The result is

              Red

              Comment


                #8
                Re: Decode image path stored outside webroot?

                Soooooooooo. I found a sort of round-a-bout way of doing things. I ended up using a5w_Decode_IFR, which takes a bunch of parameters and stuff. I wanted to avoid this function because it slowed generating my JSON. But then I found a different way to generate the JSON from the SQL query that was better than iterating through the sql::resultSet manually to make the JSON:

                Code:
                dim rsJSON as C = rs.toJSONObjectSyntax(-1,-1,.t.)
                dim folderAlias as c = "[ImagesFldr]"
                dim t as p	
                if (variable_exists("request") == .t.) then
                	t.request = request
                	t.session = session 
                	t.serversetting = serversetting
                end if
                dim fileName as c = ""
                dim repFile as c = ""
                for each json in rsJSON
                	fileName = stritran(json_extract(json.value,"REC_IMG"),"\"","")
                	if (FILE.exists(filename_decode(folderAlias+fileName))) then
                		repFile = a5w_decode_ifr(t,fileName,folderAlias)
                		json.value = stritran(json.value,fileName,repFile)
                	end if
                next
                Load/response time is much better now. Though, not perfect. Always looking for a better way to do things.

                Suggestions to make this better/faster? Does base64 encoding images improve load times at all? My "bottleneck" is the execution of code and not necessarily the size of the download.
                Last edited by TheSmitchell; 11-17-2015, 02:14 PM.
                Alpha Anywhere latest pre-release

                Comment


                  #9
                  Re: Decode image path stored outside webroot?

                  Can't you just copy the image(s) to be displayed over to session storage ?
                  Frank

                  Tell me and I'll forget; show me and I may remember; involve me and I'll understand

                  Comment


                    #10
                    Re: Decode image path stored outside webroot?

                    I am going to offer a different route altogether. Put your files/images in an Amazon S3 storage bucket, then it will not matter what instance you're on or what the root is...if I am thinking right...lol <--beers!
                    NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                    Comment

                    Working...
                    X