8 Replies Latest reply on Oct 22, 2012 11:17 AM by philmodjunk

    Using Insert From URL script for pictures, want to archive photos separately, open separately

    MichaelLawrence

      Title

      Using Insert From URL script for pictures, want to archive photos separately, open separately

      Post


           I'm currently using a script included with FMP12 Advanced, 'Insert From URL' . It's capturing a picture from a live security video camera on my network.

           As it is now, the pictures are getting stored inside the database. I'm fully aware that this is not an ideal situation for a vareity of reasons, but as it stands I can't figure out a way to make them save separately from the database. My records must be saved for 2 years from transaction date, but the photo doesn't have to be saved for more than three months.

           My script currently looks like this: Insert From URL[No dialog; Invoices::Photo; "http://192.168.1.146/image/cam1"] .

           Also, does anyone know an easier way to make this container object 'Photo' open in paint or some picture viewing software? Currently the best way to do it after the image is captured is to copy the image, and the paste into an new paint file.

        • 1. Re: Using Insert From URL script for pictures, want to archive photos separately, open separately
          schamblee

               The following link will give you instruction on how to setup a container field for external storage.

          http://www.filemaker.com/12help/html/create_db.8.27.html

               Viewing:  I don't have a camara to test but I google. jpeg images on the internet then used that url to store a image to the databases, and the image automatically came up in the container field for viewing.  What format is the picture when it is saved to the container field.  I would guess that filemaker can't determine the format of your image and that is why it can't view it.  If you can add  a filename with file extension such as jpeg. to the end of your capture path, I think it would automatically display your image.

          • 2. Re: Using Insert From URL script for pictures, want to archive photos separately, open separately
            philmodjunk

                 Export Field Contents can be used to export a copy of your picture and then open it with the application set up in your operating system settings as the default application for that file type.

            • 3. Re: Using Insert From URL script for pictures, want to archive photos separately, open separately
              MichaelLawrence

                   Thank you so much for your quick response. I'm getting the pictures to store externally instead of inside the database and it has transferred all the existing photos to the new external data source.

                   The only other issue I'm having is that I'd like to create a specific file name. I've followed the advice to creating my own variable script but I'm not sure when to call it. At first I thought it was going to be used in the 'Open storage field' but all that does is create a different directory with my variable's name. I'd really like to be able to create a new folder for each day and store the pictures inside there.

                   Another thought I was trying to figure out was, I'd like the users to be able to double click on my container field after the photo is stored in there. Is there a conditional trigger option I can set so that whenever the container field is double clicked it will automatically go to open the photo file currently stored in there?

              • 4. Re: Using Insert From URL script for pictures, want to archive photos separately, open separately
                philmodjunk

                     It's something you use with Export Field Contents:

                     Set Variable [$Path ; Get ( TemporaryPath ) & "fileName.jpg" //specify the extension that's right for your file]
                     Export Field Contents [ Container Field ; $Path]

                     You open the Specify Output File dialog and type your variable name into that dialog.

                     Note that you can extract current file names from your container fields to  use in the set variable scrpt step. Also, there are several Get functions that produce file paths to specific, standard locations within both mac and windows computers. TemporaryItems is a place to put such files so that the copies are not retained in your computer.

                • 5. Re: Using Insert From URL script for pictures, want to archive photos separately, open separately
                  MichaelLawrence

                       Awesome! I'll start trying to get these to work then.

                       But just to be clear are you saying that to export the files for storage it's fine to use the 'export data from container fields'? But when I would like to open the files that are actually stored in these fields it would be best to use the 'Export Field Contents' and store them in a temp folder and open them from there? Or that I would use Export Field Contents for both of them?

                  • 6. Re: Using Insert From URL script for pictures, want to archive photos separately, open separately
                    MichaelLawrence

                         So what I think I'm figuring out is that you can definitely set up the 'external storage for container fields' and store the files in whatever directory you want, but it has its limitations. One being that you can't specify the exact filename you want to have (all of my photos are pulled from the same location and have the same name) so if I'm relying only on the 'external store for container fields' option, I'll be stuck with thousands of images named 'cam1_1', 'cam1_2' etc.

                         The "Export Field Content" seems to be a much better option. I can input my variable in the 'Specify Output File' dialog box and get closer to the filenames that I want.

                         Phil, I really appreciate your help, you've done it more than once and I value your input.

                         I'm still having issues with two things.

                         The current setup I've got is a button that runs the 'inesrt from url' script to pull the image from the webcam, declares my variable, and then runs the 'Export Field Content' script to store it externally. I'd much rather rely on the security of having it stored by Filemaker everytime an image in inserted, but because of the naming issue I've currently turned off the 'store data externally' box. The problem I'm running into now is that I'd like to save the image with some form of a timestamp in the name. I've tried a few different ways but they all seem to give me errors. I really just want to save the photos in this manner or something close to it: '10-20-12-3:48:12PMScaleCamera.jpg'. The few get(date) or get (currenttimestamp) functions I've tried all have problems because of the "/" in the filename.

                         The other issue I'm having is with the example you gave me in your last response. I've created this script already:

                         Set Variable [$Path ; Get ( TemporaryPath ) & "fileName.jpg" //specify the extension that's right for your file] it is a .jpg
                         Export Field Contents [ Container Field ; $Path]

                         I definitely realize that storing the data in a temporary folder and opening it from there is best so we don't have two copies of the same file, but I'm assuming there has to be more to it than that. Am I crazy and dense or is there something I'm just missing? Any help would be appreciated....

                    • 7. Re: Using Insert From URL script for pictures, want to archive photos separately, open separately
                      MichaelLawrence

                           Also: I just considered the fact that if I don't have the 'External Storage' option checked, the files are all going to be stored in the database, which is something I don't want lol.

                      • 8. Re: Using Insert From URL script for pictures, want to archive photos separately, open separately
                        philmodjunk

                             I see that you have opened a new thread for this: Naming issue: storing container data externally

                             See the response that I posted to that new thread.