8 Replies Latest reply on Aug 9, 2006 2:27 PM by romeogq

    Remote file exists - with a little twist

    romeogq Level 1
      I need to know if a wmv file exists on a windows media server before I try to stream it. I don't think I can use cfftp because the file is located in the WMRoot folder, not the ftproot folder which cfftp queries.

      I've tried cfhttp, but it doesnt work. I get the same result whether the file is there or not.
      <cfhttp method="get" url="blah-blah"></cfhttp>
      <cfoutput>#cfhttp.FileContent#</cfoutput>

      Any help would be greatly appreciated.
        • 2. Remote file exists - with a little twist
          romeogq Level 1
          Thanks Dan, but I'm getting the same result. No error on either. Results are below, the .wav file does not exists, while the wmv file does.

          Code (added user and pass just in case):
          <cftry>
          <cfhttp method="get" url="65.61.124.134/SXM/121_Alonna--James/vcard.wav" username="#video_user#" password="#video_pass#"></cfhttp>
          <cfoutput>#cfhttp.FileContent#</cfoutput>
          <cfcatch type="any">
          Error
          </cfcatch>
          </cftry>
          <br />
          <cftry>
          <cfhttp method="get" url="65.61.124.134/SXM/121_Alonna--James/vcard.wmv" username="#video_user#" password="#video_pass#"></cfhttp>
          <cfoutput>#cfhttp.FileContent#</cfoutput>
          <cfcatch type="any">
          Error
          </cfcatch>
          </cftry>

          Results:
          [Reference] Ref1=http://65.61.124.134/SXM/121_Alonna--James/vcard.wav?MSWMExt=.asf Ref2=http://65.61.124.134:80/SXM/121_Alonna--James/vcard.wav?MSWMExt=.asf
          [Reference] Ref1=http://65.61.124.134/SXM/121_Alonna--James/vcard.wmv?MSWMExt=.asf Ref2=http://65.61.124.134:80/SXM/121_Alonna--James/vcard.wmv?MSWMExt=.asf
          • 3. Re: Remote file exists - with a little twist
            Level 7
            <cfhttp> doesn't throw an exception on a failed request unless you tell it
            to.

            http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000272.htm

            --
            Adam
            • 4. Remote file exists - with a little twist
              romeogq Level 1
              Ok, so I set throwonerror="yes", but guess what? I cannot throw an error if there is no error to throw. I've used cfdump and all returned data is the same. Nothing telling me if the file is there or not.

              Maybe this is an impossible mission to accomplish with CF; so if it is, someone please let me know if I'm wasting time trying to do this.
              • 5. Re: Remote file exists - with a little twist
                Level 1
                Respectfully, just because YOU can't get something to work, doesn't mean it's not possible to do in CF. That's a bit self-important, I think.

                Now. If a file being requested from a webserver is not found, the webserver should issue a 404. If you tell <cfhttp> to throwonerror, then if a 404 is returned, it will raise an exception (I have - this minute - tested this). If the webserver is not returning a 404 for a missing file, there's something wrong with the webserver. If CF is now raising an exception and you ARE getting a 404 statuscode, that is very strange.

                However you say the result of the CFHTTP is the same whether the file is there or not. This points to the webserver @ the other end not working properly. What statuscode ARE you getting back from the <cfhttp> request?

                If you use a web browser to browse to the URL, what do you get?

                --
                Adam
                • 6. Re: Remote file exists - with a little twist
                  romeogq Level 1
                  Sorry about the delay.

                  Here are the two links. The later resides on a Windows Media Server.

                  65.61.124.134/SXM/121_Alonna--James/vcard.wav (file does not exists; Windows Media Player Error Code - C00D1197: Cannot play the file)
                  65.61.124.134/SXM/121_Alonna--James/vcard.wmv (file does exists)

                  To make it easier, I've cfdumped both sets of information at http://www.southernxposuremodels.com/vtest.cfm.
                  • 7. Re: Remote file exists - with a little twist
                    Level 7
                    > Sorry about the delay.

                    NP ;-)

                    > Here are the two links. The later resides on a Windows Media Server.

                    Well I dunno how Windows Media Server is supposed to work, but I tried
                    this:

                    <cfhttp URL=" http://65.61.124.134/nonsense_file.dat" method="get"
                    result="stFile3">

                    And it returned an HTTP status of 200. Odd.

                    You should perhaps read the docs on Windows Media Server adn see if there's
                    an explanation as to why it returns "200" for every request. And maybe
                    they'll also explain how to glean if the file actually DIDN'T exist.

                    Bottom line: this is not a problem with CF, it's a problem with how WMS is
                    responding to HTTP requests, or the way we'd EXPECT WMS to respond (ie:
                    with a 404 if the file doesn't actually exist).

                    --
                    Adam
                    • 8. Re: Remote file exists - with a little twist
                      romeogq Level 1
                      Thanks Adam, I thought I might have been going crazy there for a lil while. I'll going to have to read up on the server to see if it can be forced to return a error.