1 2 3 Previous Next 40 Replies Latest reply on Jul 25, 2012 9:26 PM by JCPython

    External photo storage problem

    JCPython

      Title

      External photo storage problem

      Post

      Ok ill describe the situation...

      I created a runtime solution on filemaker pro adv 11 and have hundreds of users using it to enter there records, when i got filemaker pro adv 12 i converted my solutions master fp.7 file to fmp.12 and began creating updates for my users and allowed for them to use the import features within the program, i always use the same bindkey for my runtime updates (not sure if that helps).

       

      i tried adding a convert file script in the program to converts the users old .USR file but that proved to not work which is unknown why, or in similiar situations it will convert it to fmp12 and when they try to import it will do the script but nothing gets imported until i go to the script and click the specify button on one of the table import script steps and it gives me a pop up msg stating something about it needing a one time authorization of the file, once i authorize it and run the same script it then works, however because external storage wasnt doable in fm11 and now i use that feature in fm12, the photos are not showing up when performing the upgrade wizard to run the import script...

       

      if i continue to have the images embeded in the program then it runs extremely slow due to the themes feature which i read that its a known issue to use theme and expect the program to run slow. but when photos are store externaly it didnt seem to run as slow.

       

      in a perfect world, i would just like to have a script that when a button is clicked the user is prompted to find his prgram.USR file and it converts it, then the user can use my upgrade wiazrd which prompts them to locate the newly converted file and all the records including photos are imported into the solution.

       

      does anyone have any good script examples on how this can be done, i spent around 14 hours testing and moding scripts and more testing and i just cant seem to get anywheres....starting to wish i never upgraded to fm12.

       

      Any help would be so much appreciated! Thanks

      Justin

        • 1. Re: External photo storage problem
          philmodjunk

          I'm not sure I have a clear understanding of the problem. Do you have images stored in containers as binary files (Not store a reference) and you want to re-insert them in container fields set up with external storage?

          If so, you should be able to use a looping scrip to export the files from the current container field and then re-insert them into the new "external" container field.

          • 2. Re: External photo storage problem
            JCPython

            Phil,

            Yes thats exactly what i was trying to say, i dont know much about using the export script and and terrible at using file paths, things sometimes work on my pc but my end users will have issues, think you could give me a example script to show me how its done to move the images into the external storage?

             

            Thanks for the reply

            • 3. Re: External photo storage problem
              philmodjunk

              Put this code inside the loop through your records...

              Set Variable [$FilePath ; Value: Get (TemporaryPath) & "TempFile.jpg" ]
              Export Field Contents [ YourTable::OriginalContainerField ; $FilePath ]
              Go to Field [YourTable::newContainerField]
              Insert Picture [no dialog ; $FilePath]

              The trick to making sure your file paths work for multiple users is to use one of the get functions that returns a path to a location found on all computers both Mac and Windows. A get function can return the file path to the user's Temporary Items folder, Documents or the desktop. I'm using temporary items here so the user doesn't see any new files appear when they use the script.

              This script assumes that all pictures are all jpg files. If the pictures might be a mix of several file types, you can use a calculation to extract the correct file extension from the data in the container field.

              • 4. Re: External photo storage problem
                JCPython
                Thank you very much phil! I will put this script to work tonight and try and get it working. Can this script loop work within the scrip i already have that is used to import the records from The old runtime to the new one? I got 7 image containers for each record so i would use the set variable and export script steps for each field correct? So looking at your code... The photos arent stored in a folder located in the database folder but instead they get stored in a temperary path? What is that path?
                • 5. Re: External photo storage problem
                  philmodjunk

                  With 7 containers for each record, you'd need to adapt this code to export, then insert, once for each field.

                  The path to the temporaryItems folder is just that. It's the file path to the current user's temporary items folder. This path will differ depending on the current user's OS version. The Get function is able to produce the correct file path for the current user for all possible OS systems where your FileMaker runtime might be placed.

                  But it's a TEMPORARY location. The script exports the image to that location and then inserts it from that location into the new container field that has external storage specified. The next export field contents step will overwrite this temporary copy with the next file to be exported.

                  • 6. Re: External photo storage problem
                    JCPython
                    Ok i believe i got the idea of it! I will implament it tonight, ill start another thread for my other problem. Thanks again phil!
                    • 7. Re: External photo storage problem
                      JCPython

                      How would i extract the file extention? the only way i can see is using the fuction right to get the last 4 characters, ".xxx" but i dont see how to get the images filename...

                      • 8. Re: External photo storage problem
                        philmodjunk

                        You don't need the image's file name for the script to work, but you can extract it using the position function in combinations with the right function:

                        Let ( [ T = getAsText ( YourTable::originalContainerField ) ;
                                   L = Length ( T ) ] ;
                                   Right ( T ; L - Position ( T ; "/" ; L ; -1 ) )
                               )

                        Note: GetAsText is only needed for non "Store a reference" images so that Length returns the correct number of characters for the text in the field instead of the byte size of the image. If all image files are "store a reference", you can simplify this expression by eliminating the use of that function.

                        • 9. Re: External photo storage problem
                          JCPython

                          Yes i realized that after i posted that if i left the tempfile.jpg as is that the script still worked,

                          like i said each record has 7 photo containers, in this particular case there is has atleast one photo entry for each record, maybe 10 records contain 2 photos, when i imported the converted file i got the msg box stating "Container fields cannot be exported." i click ok and it pops up a total of 5 times then it resumes the import script and everything works great, however if i do the same thing with other converted files of the same db sometimes i get that same pop up msg 50-60 times and no photos are imported into the database.

                           

                          i cant figure out what the difference is between these files. the one file that pops up the msg 5 times and then work worked great for me, i sent the file to the user of that data and a new copy of the same runtime i use and he got the msg box about 50-60 times and no photos got imported, then he tried it all again and got the msg box 5 times and had success.

                          having it work is great but not knowing why only some files work and why they may work the 2nd time around is puzzling.

                          i seen your other post...

                          Just recalled a little idiosyncracy with Import Records that could be a factor here. Was the Converted file open or closed when the script attempted to import records from it?

                          Don't know if this is still the case with  FMP12, but importing records from a closed, password protected file triggers the password log in--even if the source file has the same account/password define as the the account/password currently used to open the target file. The FMP 11 solution is to use Open File or Perform Script to open the source file before importing from it.

                           

                          I tried opening the file in filemaker while importing the data as stated above, i tested this with a file that gives me the pop ups 50-60 times but it didnt help. and the end users dont have filemaker but just the runtime copies, how could they open the .USR files in the rutime to import into it?

                           

                          I also see a issue with creating backups from the runtime, i have a button that runs a script step to save a copy as, its saved from the runtime made in fmp12 so importing the data using matching fields should be a problem but it just doesnt work as it did before in fm11, when i try to import the backups it just gives me the 50-60 pop ups and only the records without images are imported...this maybe have something to do with the "Files" folder location that contains all the photos... things have really gotten complicated for filemaker 12.

                           

                          • 10. Re: External photo storage problem
                            philmodjunk

                            The issue you are seeing is probably the reasson for one of the design decisions made in what can and can't be done with container fields in FileMaker 12.

                            With FileMaker 11 windows, if you drag and drop a file into a container field, (Drag from an OS window, not another container field), what you get is an inserted object using OLE technology. Insert Object from the Insert Menu produces the same results.

                            Objects embedded in container fields cannot be exported and you'll get that error message. What's really bad news for you and your users is that there is no way to export those objects. The only thing you can do with them is to manually double click their container field and save a scopy of the opened image file to a known location so that you can re-insert them with the insert pciture or other FileMaker 12 compatible insert option.

                            Best method I can think of here is to use Get ( LastError ) to catch these cases at the moment it happens so that you know which file and in which container field was an embedded object. Unfortunately for this method, is the fact that you cannot use set error capture to suppress the error dialog. This, BTW, is a known issue that I have confirmed still exists in FileMaker 12. Undecided

                            • 11. Re: External photo storage problem
                              JCPython

                              So does this mean when a user has say 100 records and each record has a few photos , the photos that are store externaly in open storage cannot be exported, there for the images are all stored in a folder called "Files" (in my case) located in the installation directory, so this folder of images would need to be manually backed up by the user themselves, are is this possible to be apart of a backup script?

                               

                              • 12. Re: External photo storage problem
                                philmodjunk

                                Huh?

                                I'm not sure what you are asking here. We were talking about files inserted as an object--unique to pre filemaker 12 files on windows system. What do you mean by "Store externally in open storage"? External storage is not an option in FileMaker 11 and earlier.

                                And why would this mean that user has to manually back up the folder of images? I've outlined a script approach that can use Export Field Contents to back them up.

                                • 13. Re: External photo storage problem
                                  JCPython

                                  Sorry was late night, think i misunderstood, you when you said container fields cant be exported, i can use the script to export the container fields from the fm11 file after its been converted to the fmp12, correct? but when that is all said and done, all records for the user is now imported into his fmp12 runtime, when they go to make a backup, wether i do copy of current file or self contained file it seems to not keep the images as apart of the backup, do i need to include the export field script you showed me into the backup script as well? Im trying to get on the same page as you.

                                  • 14. Re: External photo storage problem
                                    philmodjunk

                                    That was what I had in mind and why I recommended two solution folders located next to each other. That enables you to use the filepath to your current solution file to construct the file path to the corresponding folder in the back up solution folder so that export fields can export a copy of the image to that folder and thus produces an "all in one" baked up solution folder that the user can both use to replace the original folder in case of disaster or can easily use to store complete backups or your solution on external locations or media.

                                    1 2 3 Previous Next