Giter VIP home page Giter VIP logo

Comments (3)

Garulf avatar Garulf commented on May 25, 2024

Flow Launcher can be used in portable mode allowing the use of cloud drives, git, syncthing, etc.

from flow.launcher.

1208nn avatar 1208nn commented on May 25, 2024

It's true but it really costs my space and time. Sync the whole app in cloud might have some problem for too many files.

Flowlauncher was packed with runtime. Can they be deleted if I installed .net?

I think just sync a folder wasn't difficult. In C#,we can use Microsoft.Graph.

This is an example (bad code):

using Microsoft.Graph;
using Microsoft.Identity.Client;
using System;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace OneDriveAppFolderExample{
    class Program{
        private static GraphServiceClient graphClient;
        private static string clientId = "*#*#*#*#*";
        private static string[] scopes = new string[] { "Files.ReadWrite.AppFolder" };

        static async Task Main(string[] args){
            var authProvider = new InteractiveAuthenticationProvider(clientId, scopes);
            graphClient = new GraphServiceClient(authProvider);
            var appFolder = await CreateAppFolder();
            await UploadFileToAppFolder(appFolder, @"UserData/settings");
            //This need keep flow's working directory not change
            //In file search plugin, if user use the position of the executable file as the working directory, it will not work. We need not change the working directory of the main process.
        }

        private static async Task<DriveItem> CreateAppFolder(){
            try{
                var appFolder = await graphClient.Me.Drive.Special.AppRoot
                    .Request()
                    .GetAsync();

                return appFolder;
            }
            catch (ServiceException ex){
                if (ex.StatusCode == System.Net.HttpStatusCode.NotFound){
                    var folderToCreate = new DriveItem{
                        Name = "Flow.Launcher",
                        Folder = new Folder()
                    };

                    var appFolder = await graphClient.Me.Drive.Special.AppRoot
                        .Children
                        .Request()
                        .AddAsync(folderToCreate);

                    return appFolder;
                }
                else{
                    throw;
                }
            }
        }

        private static async Task UploadFileToAppFolder(DriveItem appFolder, string localFilePath){
            using (var fileStream = System.IO.File.OpenRead(localFilePath)){
                var uploadedFile = await graphClient.Me.Drive.Items[appFolder.Id]
                    .ItemWithPath(System.IO.Path.GetFileName(localFilePath))
                    .Content
                    .Request()
                    .PutAsync<DriveItem>(fileStream);

                Console.WriteLine("Uploaded file ID: " + uploadedFile.Id);
            }
        }
    }

    public class InteractiveAuthenticationProvider : IAuthenticationProvider    {
        private IPublicClientApplication _msalClient;
        private string[] _scopes;

        public InteractiveAuthenticationProvider(string clientId, string[] scopes){
            _msalClient = PublicClientApplicationBuilder.Create(clientId).Build();
            _scopes = scopes;
        }

        public async Task AuthenticateRequestAsync(HttpRequestMessage request){
            var authResult = await _msalClient.AcquireTokenInteractive(_scopes).ExecuteAsync();
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
        }
    }
}

from flow.launcher.

onesounds avatar onesounds commented on May 25, 2024

We want to create this feature, but we don't have anyone to work on it now.
(Sadly, The simple setting backup/restore feature too.)

If you know how to write code, please make a PR.

from flow.launcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.