예제 #1
0
        public void Get(string remotename, System.IO.Stream stream)
        {
            try
            {
                var url = string.Format("{0}/b/{1}/o/{2}?alt=media", API_URL, 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;
            }

        }
예제 #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);
        }