DD.WellWorkover.Cloud/ConsoleApp1/Program.cs

40 lines
1.4 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 service = new GoogleDriveService();
//var files = serviceWrapper.GetAllFiles();
// 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 = service.UploadFile(fileStream, fileInfo.Name, "", "uploaded");
service.CreatePublicPermissionForFile(uploadedFileId);
var webLink = service.GetFileWebLink(uploadedFileId);
Console.WriteLine(webLink);
2021-10-06 16:30:46 +05:00
}
}
}