8 Replies Latest reply on Sep 24, 2014 9:34 AM by justinc

    How to NOT download a file?


      I have a link from a vendor that accesses their website and returns a chunk of data - records that have been updated since the last time, kind of a thing. I am using 'Insert from URL' and would like to just plop the results (text/CSV) into a field and then process from there. However, it appears that I am only able to download it as a complete file. I.e. I can only save it to a container field, and not a simple text field.


      Yes, I could export the container field and then import the file, but that seems like unnecessary steps. However, I am not quite sure what to tell this vendor about how FileMaker needs the response data formatted in order to get it as plain text. Any suggestions on what might need to be changed on his side (or mine)? The response headers look similar to this:


      Cache-Controlno-store, no-cache, must-revalidate, post-check=0, pre-check=0
      Content-Dispositionattachment; filename="exported_datarecords.csv"
      ServerApache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips mod_bwlimited/1.4





        • 1. Re: How to NOT download a file?

          You will only be able to add the FILE ITSELF into a container field. However, if your client is supplying you with a csv file you should be able to import the CONTENTS of that file into text fields in your FM database—use Import Records (in the File menu), choose your source file and map what data goes where in the subsequent dialog. Each line of data will be added as a record in your DB.

          • 2. Re: How to NOT download a file?

            Do you use our MBS Plugin? You could download the file using CURL functions and get the result as text for processing.





            • 3. Re: How to NOT download a file?
              Mike Duncan

              It is the "Content-Disposition" header that is causing your browser (webkit) to save as a file instead of rendering the content. If this is a vendor that will work with you, perhaps you could ask them to add a little bit of code that would allow you to specify if you want that header included or not.


              This could be an extra parameter you can send in the url "dl=false" or something similar, that their php page can test for before including the content-disposition header.


              If they won't work with you on it, some external scripting or plugin might be needed to process it, as has been suggested.

              • 4. Re: How to NOT download a file?

                Look at this link. Use of the "Import Records" > Folders option will let you import the content into a record.  Make sure you test this first, so you understand how it works.





                This requires you to download the file, but you can still push it to a folder and import the content.

                • 5. Re: How to NOT download a file?


                       This is exactly what I was looking for.  I think the vendor will be flexible and can accommodate this request.  If that doesn't work, I will have to resort to the normal methods of exporting/re-importing or a plugin.  MBS has lots of different features that are intriguing.  Josh's point about importing a folder so files end up in a single field is interesting, too; it would allow for a bit more flexibility in handling the result, if the don't-save-as-a-file option doesn't pan out.


                  Do you know, perhaps, if this solution (the content-disposition) will apply to Windows based FMPro clients as well? 


                  --  Justin

                  • 6. Re: How to NOT download a file?
                    Mike Duncan

                    It should, earlier versions of IE might not have handled it as well, but any recent versions for a while now have handled it correctly.

                    • 7. Re: How to NOT download a file?

                      Just a clarification for others reading.


                      My suggestion takes the content of the file ( not the file itself ) and inserts it into the field you map it to in the import. Each file will be inserted into a separate record. It can take a little to get your mind around how it works, but I've often used this to pull the contents into field so I can parse it out and plug the data where it belongs in another table.  Plus it's a tad faster in many cases than importing the each row in the csv to it's own record during the import...or at least it makes the actual import faster, which can be beneficial over a WAN.

                      • 8. Re: How to NOT download a file?


                          I spoke with the web hosting guy and he was able to remove the 'Content-Disposition' flag from the headers; with that done the file/data-stream came through nicely into the field.  Thanks again for the pointer.