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; }
public override Stream CreateDownloadStream(IStorageProviderSession session, ICloudFileSystemEntry fileSystemEntry) { // build the url string url = GetResourceUrl(session, fileSystemEntry, null); // get the session creds ICredentials creds = session.SessionToken as ICredentials; // Build the service DavService svc = new DavService(); // create the webrequest WebRequest request = svc.CreateWebRequest(url, WebRequestMethodsEx.Http.Get, creds.GetCredential(null, null), false, null); // create the response WebResponse response = svc.GetWebResponse(request); // get the data Stream orgStream = svc.GetResponseStream(response); BaseFileEntryDownloadStream dStream = new BaseFileEntryDownloadStream(orgStream, fileSystemEntry); // put the disposable on the stack dStream._DisposableObjects.Push(response); // go ahead return dStream; }
public override Stream CreateDownloadStream(IStorageProviderSession session, ICloudFileSystemEntry fileSystemEntry) { // build the url var url = GetDownloadFileUrlInternal(session, fileSystemEntry); // build the service var svc = new OAuthService(); // get the dropbox session var dropBoxSession = session as DropBoxStorageProviderSession; // create webrequst var requestProtected = svc.CreateWebRequest(url, WebRequestMethodsEx.Http.Get, null, null, dropBoxSession.Context, (DropBoxToken) dropBoxSession.SessionToken, null); // get the response var response = svc.GetWebResponse(requestProtected); // get the data stream var orgStream = svc.GetResponseStream(response); // build the download stream var dStream = new BaseFileEntryDownloadStream(orgStream, fileSystemEntry); // put the disposable on the stack dStream._DisposableObjects.Push(response); // go ahead return dStream; }