13 Replies Latest reply: Sep 22, 2010 9:18 AM by 843790 RSS

    Open a file from anywhere - with credentials?

    843790
      Hi;

      Is there a way to open a file from anywhere where I give the uri and uname/password and it gives me back a Stream to read? Including:

      1. ftp - with/without credentials
      2. http - anon, basic, digest, & windows authentication
      3. REST where you must do basic on the first request (anon returns an error message as an html page).
      4. share on the same domain - requires a different user's credentials.
      5. share on a different domain
      6. share on a workgroup computer
      7. share on a non-Windows server
      8. ???


      thanks - dave

      Edited by: david@windward.net on Sep 15, 2010 2:04 PM
        • 1. Re: Open a file from anywhere - with credentials?
          masijade
          If you're speaking about "providing" the file, then, well, configure all those services, of course.

          If you're speaking of reading one, then, well, try all those services, of course.

          IOW: AFAIK, not as a prefinished API/Package. Write one, if you're the receiving side. Or even, if you're the server side, right one to configure them.

          Edit: It will, obviously, take time to try them all so especially performant, something like this, will not be.
          • 2. Re: Open a file from anywhere - with credentials?
            jschellSomeoneStoleMyAlias
            david@windward.net wrote:
            Is there a way to open a file from anywhere where I give the uri and uname/password and it gives me back a Stream to read? Including:
            No.

            Each of the items you mentioned represent specific and significantly different protocols and layers at which the protocol is implemented.

            For example windows file sharing occurs at the OS level dependent on the user that is logged in to windows.
            While FTP requires an application controlled protocol which depends on the user that is logged in via the ftp server.

            Besides different protocols there are different errors as well.

            Finally I doubt there are real business cases that would support requiring all of those. If I need to read a spreadsheet that the accounting department produces I am never going to find it via a url because there is no need to push it to a web server. Conversely I am not going to access Amazon via a ftp file.
            • 3. Re: Open a file from anywhere - with credentials?
              843790
              Hi;

              I just wanted to add the use case so you would understand why we need to handle all cases. We have a reporting system we sell and one thing users can do is import images from an external source. Some users put their images on a web or FTP server requiring credentials. Others put it on a server that requires credentials. And we're now getting requests to pull from SharePoint.

              Thanks Dave
              • 4. Re: Open a file from anywhere - with credentials?
                843790
                Ok, but did you read first reply? There likely would not be prefinished API ready for this. You might have to develop it.
                • 5. Re: Open a file from anywhere - with credentials?
                  3004
                  david@windward.net wrote:
                  Hi;

                  I just wanted to add the use case so you would understand why we need to handle all cases. We have a reporting system we sell and one thing users can do is import images from an external source. Some users put their images on a web or FTP server requiring credentials. Others put it on a server that requires credentials. And we're now getting requests to pull from SharePoint.
                  1. So you have the requirement to be able to get a file via a specific set of sources/protocos/formats, not "from anywhere" or "all cases".

                  2. For each of those cases you must support, as already pointed out, there will be an appropriate server responding to requests. If there is not, you can't get them.

                  3. For those various protocols, there may exist in the core API or in a third-party library a means to access a file via a URL. For those cases where no such API exists, you may be able to write your own. Or you may come to the realization that it makes more sense to abandon the URL notion in these cases.

                  It's up to you to do the research for the individual cases you have to support. It would not be reasonable to expect that there exists a solution that will work for "all cases."
                  • 6. Re: Open a file from anywhere - with credentials?
                    843790
                    [Apache Commons VFS|http://commons.apache.org/vfs/] might have what you're looking for.

                    Just a heads-up: REST is not its own protocol, it's just a set of guidelines on how to use HTTP, therefore it hasn't got its own URIs either,
                    • 7. Re: Open a file from anywhere - with credentials?
                      843790
                      Hi;

                      Thank you, I will look at VFS.

                      Yes on REST - it's http but you have to send a BASIC set of credentials and request a contnet type of XML because otherwise you get back HTML rather than a login error code. So same protocol, but you must do it a very specific way.

                      thanks - dave
                      • 8. Re: Open a file from anywhere - with credentials?
                        843790
                        Hi;

                        Yes. Any suggestion about how we should read a file from a server that needs credentials?

                        thanks - dave
                        • 9. Re: Open a file from anywhere - with credentials?
                          3004
                          david@windward.net wrote:
                          Hi;

                          Yes. Any suggestion about how we should read a file from a server that needs credentials?
                          [:headdesk:|http://i365.photobucket.com/albums/oo97/Sarklor/headdesk.gif]
                          • 10. Re: Open a file from anywhere - with credentials?
                            jschellSomeoneStoleMyAlias
                            david@windward.net wrote:
                            Hi;

                            I just wanted to add the use case so you would understand why we need to handle all cases.
                            I suggest that you actually ask customers what they want initially instead of assuming that you need all of them initially.
                            We have a reporting system we sell and one thing users can do is import images from an external source. Some users put their images on a web or FTP server requiring credentials. Others put it on a server that requires credentials. And we're now getting requests to pull from SharePoint.
                            Fine. So you have the following task that has the following steps.
                            1. Define source of image and where to store it.
                            2. Create retriever based on 1.
                            3. Run instance of 2
                            4. Log errors from 3 or put retrieved file into location specified by 1.

                            In the above step 2 is a plug in that represents different ways of retrieving information.

                            And expanding on something that was said before you have a HUGE task in front of you in terms of supporting everything that you list above.

                            For example using only ftp these are some of the things I see.
                            1. There are at least three types of secure "ftp" servers. The protocol for handling security is different for each.
                            2. Although FTP is a protocol the implementation of how the servers work can be substantially different. For general handling the will likely require scripting for each targetted server.
                            3. Locations on FTP servers not necessarily simple. Examples.
                            ...a. Login to server. Cd to a directory. Get a file which has a date as part of the name.
                            ...b. Login to a server. Cd to a directory with a timestamp in the name. Get a file.
                            ...c. Login to a server. Get a file which has a random name based on the last creation timestamp of each file.

                            Note that FTP is actually easier than some of the other cases.
                            And in the above I didn't deal with any of the possible errors.
                            • 11. Re: Open a file from anywhere - with credentials?
                              jschellSomeoneStoleMyAlias
                              david@windward.net wrote:
                              Hi;

                              Yes. Any suggestion about how we should read a file from a server that needs credentials?
                              As a general question that is meaningless.

                              I would suggest that the first step is that you need to learn how to use ONE of the protocols that you listed. You need to programmatically access a file using a secure server. FTP is a suitable choice (you MUST choose a secure type of FTP however.)

                              After that then you do the same using a completely different protocol. HTTP (following FTP) would be a good choice.
                              • 12. Re: Open a file from anywhere - with credentials?
                                843790
                                Hi;

                                All very good points (the joys of being a library vendor - everyone wants everything). I was hoping that Sun had come up with something like JDBC for addressing this. Oh well...

                                thanks - dave
                                • 13. Re: Open a file from anywhere - with credentials?
                                  3004
                                  david@windward.net wrote:
                                  Hi;

                                  All very good points (the joys of being a library vendor - everyone wants everything). I was hoping that Sun had come up with something like JDBC for addressing this. Oh well...

                                  thanks - dave
                                  I think I see where you're seeing a parallel. JDBC allows a single set of interfaces for interacting with most any vendor's DB, so why not something similar for remote files, right?

                                  The difference is that, after JDBC came out, each interested vendor (or maybe in some cases an interested 3rd party) provided a driver that bridges the gap between the abstract, general-purpose JDBC and the vendor's custom protocol.

                                  Even if Sun came out with a similar API for remote files, vendors or third parties would have to provide bridges, one by one. Then too, one could argue that there's more common ground among the various DBs than there is among the various remote file access protocols.