DD.WellWorkover.Cloud/ConsoleApp1/Program.cs

42 lines
1.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Google.Apis.Drive.v3.Data;
namespace ConsoleApp1
{
//var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
// .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
// .Options;
//var context = new AsbCloudDbContext(options);
class Program
2021-10-03 20:08:17 +05:00
{
2021-07-28 09:47:13 +05:00
static void Main(/*string[] args*/)
{
var serviceWrapper = new GoogleDriveFilesService();
//var files = serviceWrapper.GetAllFiles();
var service = serviceWrapper.GetService();
// foreach (var file in files)
// {
// var permission = new Permission() { Type = "anyone", Role = "reader"};
// var createRequest = service.Permissions.Create(permission, file.Id);
// createRequest.Execute();
// Console.WriteLine(file.WebViewLink);
// }
var path = "/home/cult/First.xlsx";
var fileInfo = new FileInfo(path);
var fileStream = System.IO.File.Open(path, FileMode.Open);
var uploadedFileId = serviceWrapper.UploadFile(fileStream, fileInfo.Name, "", "uploaded");
var permission = new Permission() { Type = "anyone", Role = "reader"};
var addPermissionRequest = service.Permissions.Create(permission, uploadedFileId);
addPermissionRequest.Execute();
var file = serviceWrapper.GetFileById(uploadedFileId);
Console.WriteLine(file.WebViewLink);
2021-10-06 16:30:46 +05:00
}
}
}