예제 #1
0
        public GoogleDriveStream(GoogleDriveStorage storage, Google.Apis.Drive.v2.Data.File file)
        {
            this.storage = storage;
            this.file    = file;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(file.DownloadUrl));

            request.Headers.Add("Authorization", storage.Credential.Token.TokenType + " " + storage.Credential.Token.AccessToken);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception("Could not retrieve file stream");
            }

            using (Stream responseStream = response.GetResponseStream())
                responseStream.CopyTo(dataStream);

            dataStream.Seek(0, SeekOrigin.Begin);
        }
예제 #2
0
 public GoogleDriveDirectory(GoogleDriveStorage storage, GoogleDriveDirectory parent, Google.Apis.Drive.v2.Data.File folder)
 {
     this.storage = storage;
     this.parent  = parent;
     this.folder  = folder;
 }
예제 #3
0
 public GoogleDriveFile(GoogleDriveStorage storage, GoogleDriveDirectory parent, Google.Apis.Drive.v2.Data.File file)
 {
     this.storage = storage;
     this.parent  = parent;
     this.file    = file;
 }