Exemplo n.º 1
0
        public override Stream CreateDownloadStream(IStorageProviderSession session, ICloudFileSystemEntry fileSystemEntry)
        {
            // get the session creds
            ICredentials creds = session.SessionToken as ICredentials;

            // get the full path
            String uriPath = GetResourceUrl(session, fileSystemEntry, null);

            // get the ftp request
            FtpWebRequest ftp = (FtpWebRequest)_ftpService.CreateWebRequest(uriPath, WebRequestMethodsEx.Ftp.DownloadFile, creds, false, null);

            // set request to download a file in binary mode
            ftp.UseBinary = true;

            // create the response
            WebResponse response = _ftpService.GetWebResponse(ftp);

            // get the data
            Stream orgStream = _ftpService.GetResponseStream(response);

            BaseFileEntryDownloadStream dStream = new BaseFileEntryDownloadStream(orgStream, fileSystemEntry);

            // put the disposable on the stack
            dStream._DisposableObjects.Push(response);

            // go ahead
            return(dStream);
        }