13 Replies Latest reply on Sep 22, 2011 11:27 AM by sksmith2517

    Container image reference issue across system platforms

    Kobyashi

      Title

      Container image reference issue across system platforms

      Your post

      Using FMS 10 Advanced, with users on both Mac FM and PC FM clients I have an issue with inserting references to images in container fields.

      Someone is likely to produce a better way of doing this.

      I have a table of tenants and a table of images. Users need to add images of a tenant to the image table and these images need to be stored on a server. Therefore the container will only contain a reference.

      To facilitate this I have a container field named imageData and a global container field called ximageData. When users add an image a script imports it to the ximageData field and then export the data using a prefdefined file path and a newly calculated file name to a folder on a server. If successful a reference to the saved image file is inserted as a reference in to the imageData field and this is what is shown on a layout.

      This while process works well except that the image reference is OS specific. That is to say, if the user is using a pc client then it inserts a reference of 'imagemac:' while for a pc it will be 'imagepc:' with the appropriate path to the server and image for the operating system. Therefore, if I upload an image using a PC FM client then it wont be visible to someone using a mac client.

      What's the solution here? What am I doing wrongly?

       

        • 1. Re: Container image reference issue across system platforms
          philmodjunk

          You can define a calculation that returns a "container" type. This calculation can use Get ( SystemPlatform ) to identify whether the user has a Mac or Windows platform. It can then use the filepath portion of the actual container field to compute a platform specific path to the image file.

          This assumes that all Mac users mount the shared directory where the images in exactly the same way and that all windows users mount the shared directory in exactly the same way so that all users have a consistent and predictable filepath to the image file.

          • 2. Re: Container image reference issue across system platforms
            Kobyashi

            I'm not certain I understand how this helps. My problem is where the image comes to be viewed on a mac when a pc has uploaded the image because the image reference already in the container will be for the PC path.

            • 3. Re: Container image reference issue across system platforms
              philmodjunk

              The calculation computes the correct path for the current platform and thus the image displays for either platform. With the right calculation, you can insert the image by reference from either platform into the Container Data field and still use the Container calculation field to correctly display the image.

              • 4. Re: Container image reference issue across system platforms
                Kobyashi

                I'm sorry to appear so dense but perhaps I've been trying to get this to work for so long I need to take a step back.

                Are you saying that the same reference gets entered in to the container regardless of whether the image is inserted by someone using a PC or Mac client?

                So the process goes, the file image file is inserted in full in to the global containter field. This is then exported to the server and the location of the file on the server will be inserted in to the real container. The data in the global image container is then erased.

                When reference should I be inserting in to the containter after export? image:/ imagemac:/ imagewin// ?

                Thank you for your interest so far.

                • 5. Re: Container image reference issue across system platforms
                  philmodjunk

                  Nope, that's not what I'm describing here. Bear with me and let's take another run at it.

                  You have a container field for storing a reference to the image. From a Mac you click in the field and choose insert picture with the store by reference option selected. A file path to the actual file is entered in the container field with a format like this:

                  Imagemac: /Drivename/Foldername1/FolderName2/Filename.jpg

                  If you insert the same image from a Windows platform you will get something like this:

                  Imagewin: /DiveLetter:/Foldername1/FolderName2/Filename.jpg

                  Note that the latter part of the file path is the same for both platforms and the first part will be different for the two platforms, but all filepaths to your images stored at FolderName2 will start with one or the other of these two filepaths.

                  Thus, once you've inserted the image reference, you can use either filepath to compute the filepath for the other platform. That enables you to define a calculation field that will use the filepath stored in the image's container field plus the results of Get (SystemPlatform) to correctly display the image for the current user.

                  • 6. Re: Container image reference issue across system platforms
                    Kobyashi

                    I see this but believed that the reference was permanent once inserted and could only be changed by reinserting an image. So, if I insert the image using a mac and the reference is Imagemac: /Drivename/Foldername1/FolderName2/Filename.jpg, isn't that reference always in this field? How do I change it?

                    I'm convince i'm being really stupid, trust me i'm not, but I just can't get this.

                     

                    • 7. Re: Container image reference issue across system platforms
                      philmodjunk

                      Keep in mind that I'm describing the use of two container fields. Container Field 1 stores the reference to the file as it was inserted. Container Field 2 is a calculation field that uses the path stored in Container Field 1 and modifies it, as needed, to correctly refer to the image file for whichever platform the current user is using to access the database.

                      To define field 2, you'd define a calculation field and select "container" as its return type.

                      Here's a test that can get you started.

                      Create a New FileMaker File with two container fields named, ImageMac and ImageWin.

                      Define two corresponding calculation fields that return text, called ImageDataMac and ImageDataWin.

                      Define the calculation for ImageDataMac by simply putting the name of the corresponding container field, ImageMac in the specify calculation field. Do the same for ImageDataWin, but use ImageWin instead of ImageMac.

                      Put all four fields on a layout and size the ImageData fields to be at least 3 lines of text tall.

                      Now put the file up on your server and open the file on a windows machine and insert a reference to an image file into ImageWin. Now switch to a mac, open the file and insert the same exact image file into ImageMac. Now note the two filepaths to see exactly how you'll need to construct a calculation in a separate calculation field that will change with the platform selected to properly display the image.

                      • 8. Re: Container image reference issue across system platforms
                        Kobyashi

                        I see. I didn't catch on that two fields would be used and then the correct one would be shown based on the corresponding OS. I'll give this a shot tomorrow.

                         

                        Thanks ever so much for the explanation and the patience.

                         

                        • 9. Re: Container image reference issue across system platforms
                          philmodjunk

                          Sorry but that's still not it. Field1 is for data entry. Field2 is for cross platform display...

                          • 10. Re: Container image reference issue across system platforms
                            Kobyashi

                            Got it. Didn't get it at first. Sometimes this happens when you're staring at something for such a long time.

                            I do have one question which I hope you can help with. So, now I have my calulcations for both windows and mac based operating systems I can adjust the calculation in the image container accordingly. However, originally I was inserting a reference by saying the field contents equals a field which contains the path to the image, am I inserting the entire image or is it still a reference?

                            • 11. Re: Container image reference issue across system platforms
                              philmodjunk

                              You are still entering the reference into Field 1. That's what the calculation in field 2 looks for in order to correctly compute a platform compatible file reference.

                              • 12. Re: Container image reference issue across system platforms
                                sksmith2517

                                Phil, This is exactly what I needed.  Thank you so much for once again sharing such expertise with those of us who are not as advanced.

                                • 13. Re: Container image reference issue across system platforms
                                  sksmith2517

                                  This no longer works for me - Help.  Our server crashed and I'm told it was replaced with nothing but a new box, the same system software. Also simultaneously my Mac was upgraded to Lion.  Now I can no longer view referenced file from the other platform.  It does still work with my sample database I created (CrossCheck) when I changed the name of the old server to the name of the new server - it still works. This is the file I created according to directions in this thread.  So I am convinced that my problem lies within my real database field definitions.  but what is happening now? Get on with it you say - so:

                                  When I insert the referenced file into the container field, the doc name field returns the text "file:" in front of the actual file name. When I try to view the file on the same platform, it works.  But not on the other platform. On the other platform, when I try to view it, it get the message:

                                   The file "file"CollinsFinances.txt" could not be found and is required to complete this operation.  That's my problem.  And then when I click OK to that message and it takes me to a choose file dialog box, and I choose the file (which should never have to happen), it still won't open, just repeats the same file can't be found message.  So somehow my code is now wrong.

                                  The 3 Field definitions I am using are:

                                  1. Doc_Finance (Container field) (This is where I insert the referenced file)
                                  2. Doc_Finance_Name  = Calculation: GetAsText ( Doc Finance ) (This is where it shows the path) (and is now showing the file: in front of the actual file name)
                                  3. GetFinanceviaOS:
                                    Case (Get ( SystemPlatform ) = "-2"; "filewin://James/go/CCWDataFiles/PartnerFinances/" & Doc_Name_Finance;
                                    Case (Get ( SystemPlatform ) = "1"; "filemac:/GO/CCWDataFiles/PartnerFinances/" & Doc_Name_Finance))

                                  Thanks for any help.  BTW - should I have started a new post and simply referenced this thread?