示例#1
0
    public void Get(string remotename, System.IO.Stream stream)
    {
        // Prevent repeated download url lookups
        if (m_filecache.Count == 0)
        {
            foreach (var file in List()) /* Enumerate the full listing */ } {
    }

    var fileId = GetFileEntries(remotename).OrderByDescending(x => x.createdDate).First().id;

    var req  = m_oauth.CreateRequest(WebApi.GoogleDrive.GetUrl(fileId));
    var areq = new AsyncHttpRequest(req);

    using (var resp = (HttpWebResponse)areq.GetResponse())
        using (var rs = areq.GetResponseStream())
            Duplicati.Library.Utility.Utility.CopyStream(rs, stream);
}
示例#2
0
        public void Get(string remotename, System.IO.Stream stream)
        {
            // Prevent repeated download url lookups
            if (m_filecache.Count == 0)
            {
                List();
            }

            var fileid = GetFileEntries(remotename).OrderByDescending(x => x.createdDate).First().id;

            var req  = m_oauth.CreateRequest(string.Format("{0}/files/{1}?alt=media", DRIVE_API_URL, fileid));
            var areq = new AsyncHttpRequest(req);

            using (var resp = (HttpWebResponse)areq.GetResponse())
                using (var rs = areq.GetResponseStream())
                    Duplicati.Library.Utility.Utility.CopyStream(rs, stream);
        }
示例#3
0
    public void Get(string remotename, System.IO.Stream stream)
    {
        // Prevent repeated download url lookups
        if (m_filecache.Count == 0)
        {
            foreach (var file in List()) /* Enumerate the full listing */ } {
    }

    var fileid = GetFileEntries(remotename).OrderByDescending(x => x.createdDate).First().id;

    var req  = m_oauth.CreateRequest(string.Format("{0}/files/{1}?alt=media{2}", DRIVE_API_URL, fileid, m_useTeamDrive ? "&supportsTeamDrives=true" : string.Empty));
    var areq = new AsyncHttpRequest(req);

    using (var resp = (HttpWebResponse)areq.GetResponse())
        using (var rs = areq.GetResponseStream())
            Duplicati.Library.Utility.Utility.CopyStream(rs, stream);
}
示例#4
0
        public void Get(string remotename, System.IO.Stream stream)
        {
            try
            {
                var url  = WebApi.GoogleCloudStorage.GetUrl(m_bucket, Library.Utility.Uri.UrlPathEncode(m_prefix + remotename));
                var req  = m_oauth.CreateRequest(url);
                var areq = new AsyncHttpRequest(req);

                using (var resp = areq.GetResponse())
                    using (var rs = areq.GetResponseStream())
                        Library.Utility.Utility.CopyStream(rs, stream);
            }
            catch (WebException wex)
            {
                if (wex.Response is HttpWebResponse && ((HttpWebResponse)wex.Response).StatusCode == HttpStatusCode.NotFound)
                {
                    throw new FileMissingException();
                }
                else
                {
                    throw;
                }
            }
        }