2021-10-26 17:22:32 +05:00
|
|
|
|
using System;
|
2021-10-27 15:00:58 +05:00
|
|
|
|
using System.Collections.Generic;
|
2021-10-26 17:22:32 +05:00
|
|
|
|
using System.IO;
|
2021-10-27 15:00:58 +05:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Google.Apis.Drive.v3.Data;
|
2021-10-26 17:22:32 +05:00
|
|
|
|
|
|
|
|
|
namespace ConsoleApp1
|
2021-04-02 17:28:07 +05:00
|
|
|
|
{
|
2021-09-15 10:43:46 +05:00
|
|
|
|
//var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
|
|
|
|
// .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
|
|
|
|
// .Options;
|
|
|
|
|
//var context = new AsbCloudDbContext(options);
|
|
|
|
|
|
2021-04-02 17:28:07 +05:00
|
|
|
|
class Program
|
2021-10-03 20:08:17 +05:00
|
|
|
|
{
|
2021-07-28 09:47:13 +05:00
|
|
|
|
static void Main(/*string[] args*/)
|
2021-04-02 17:28:07 +05:00
|
|
|
|
{
|
2021-10-27 17:00:27 +05:00
|
|
|
|
var service = new GoogleDriveService();
|
2021-10-26 17:22:32 +05:00
|
|
|
|
|
2021-10-27 15:00:58 +05:00
|
|
|
|
//var files = serviceWrapper.GetAllFiles();
|
2021-10-27 17:00:27 +05:00
|
|
|
|
|
2021-10-27 15:00:58 +05:00
|
|
|
|
// 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);
|
|
|
|
|
// }
|
2021-10-26 17:22:32 +05:00
|
|
|
|
|
2021-10-27 15:00:58 +05:00
|
|
|
|
var path = "/home/cult/First.xlsx";
|
2021-10-26 17:22:32 +05:00
|
|
|
|
var fileInfo = new FileInfo(path);
|
2021-10-27 15:00:58 +05:00
|
|
|
|
var fileStream = System.IO.File.Open(path, FileMode.Open);
|
2021-10-27 17:00:27 +05:00
|
|
|
|
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
|
|
|
|
}
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|
|
|
|
|
}
|