Example #1
0
        public async Task <FileSystemResult <IFileSystem> > InitAsync(string fname, IOAuthProvider provider, Dictionary <string, object> settings, string userauthorization = null)
        {
            FileSystemResult <GoogleDriveFileSystem> r = await GoogleDriveFileSystem.Create(fname, provider, settings, Name, userauthorization);

            if (!r.IsOk)
            {
                return(new FileSystemResult <IFileSystem>(r.Error));
            }
            GoogleDriveFileSystem f = r.Result;

            if (settings.ContainsKey(AcknowledgeAbuse) && (settings[AcknowledgeAbuse] is bool))
            {
                f.AckAbuse = (bool)settings[AcknowledgeAbuse];
            }
            return(new FileSystemResult <IFileSystem>(f));
        }
        public static async Task <FileSystemResult <GoogleDriveFileSystem> > Create(string fname, IOAuthProvider provider, Dictionary <string, object> settings, string pluginanme, string userauthorization = null)
        {
            GoogleDriveFileSystem am = new GoogleDriveFileSystem(provider);

            am.FS                  = am;
            am.FsName              = fname;
            am.OAuth.OAuthUrl      = GoogleOAuth;
            am.OAuth.EndPointUrl   = null;
            am.OAuth.OAuthLoginUrl = GoogleOAuthLogin;
            am.OAuth.DefaultScopes = GoogleScopes;
            bool userauth = !string.IsNullOrEmpty(userauthorization);

            if (userauth)
            {
                am.DeserializeAuth(userauthorization);
            }
            FileSystemResult r = await am.OAuth.Login(settings, pluginanme, userauth, false);

            if (!r.IsOk)
            {
                return(new FileSystemResult <GoogleDriveFileSystem>(r.Error));
            }
            r = await am.OAuth.MayRefreshToken();

            if (!r.IsOk)
            {
                return(new FileSystemResult <GoogleDriveFileSystem>(r.Error));
            }
            r = await am.PopulateAsync();

            if (!r.IsOk)
            {
                return(new FileSystemResult <GoogleDriveFileSystem>(r.Error));
            }
            return(new FileSystemResult <GoogleDriveFileSystem>(am));
        }
 public GoogleDriveFile(string parentpath, GoogleDriveFileSystem fs) : base(parentpath, fs, GoogleDriveMappings.Maps)
 {
 }
 public GoogleDriveObject(string parentname, GoogleDriveFileSystem fs, Mappings maps) : base(parentname, maps)
 {
     FS = fs;
 }
 public GoogleDriveDirectory(string parentpath, GoogleDriveFileSystem fs) : base(parentpath, fs, GoogleDriveMappings.Maps)
 {
     IsPopulated = false;
 }