forked from ddrilling/AsbCloudServer
Update nuget packs
This commit is contained in:
parent
d3daef5b17
commit
9ca7bf75e7
@ -6,11 +6,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.1">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.6">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.2" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -28,14 +28,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ClosedXML" Version="0.95.4" />
|
||||
<PackageReference Include="FluentValidation.AspNetCore" Version="11.0.2" />
|
||||
<PackageReference Include="Google.Apis.Drive.v3" Version="1.57.0.2684" />
|
||||
<PackageReference Include="itext7" Version="7.2.2" />
|
||||
<PackageReference Include="ClosedXML" Version="0.96.0" />
|
||||
<PackageReference Include="FluentValidation.AspNetCore" Version="11.2.2" />
|
||||
<PackageReference Include="itext7" Version="7.2.3" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.18.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.18.0" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.23.1" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.23.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -7,12 +7,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="Moq" Version="4.18.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
||||
<PackageReference Include="Moq" Version="4.18.2" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
@ -9,12 +9,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.6" />
|
||||
<PackageReference Include="protobuf-net" Version="3.1.4" />
|
||||
<PackageReference Include="protobuf-net.AspNetCore" Version="3.0.101" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.3.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.8" />
|
||||
<PackageReference Include="protobuf-net" Version="3.1.17" />
|
||||
<PackageReference Include="protobuf-net.AspNetCore" Version="3.1.17" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -8,13 +8,15 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Connected Services\**" />
|
||||
<Compile Remove="Properties\**" />
|
||||
<EmbeddedResource Remove="Connected Services\**" />
|
||||
<EmbeddedResource Remove="Properties\**" />
|
||||
<None Remove="Connected Services\**" />
|
||||
<None Remove="Properties\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
|
||||
<PackageReference Include="Google.Apis.Drive.v3" Version="1.57.0.2684" />
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
@ -32,9 +34,4 @@
|
||||
<ProjectReference Include="..\AsbCloudInfrastructure\AsbCloudInfrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,145 +0,0 @@
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Apis.Auth.OAuth2.Flows;
|
||||
using Google.Apis.Auth.OAuth2.Responses;
|
||||
using Google.Apis.Drive.v3;
|
||||
using Google.Apis.Drive.v3.Data;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.Util.Store;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
// usage example at the very bottom
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
public class GoogleDriveService
|
||||
{
|
||||
private readonly DriveService service;
|
||||
|
||||
public GoogleDriveService()
|
||||
{ // ключи для почты asbautodrilling@gmail.com.
|
||||
var tokenResponse = new TokenResponse
|
||||
{
|
||||
AccessToken = "ya29.a0ARrdaM-lM7q0TIC_DXixR4oW63QUftjSPHl-8nIdvZwtqA8Z1bXtlYpDrQXj9UFTjW8FW8uqPMrdamUSp4kO4a9JX7FddkBWxaJ_omSJpqzDfnHTHA_7-zGMUohaAsmPLsQtFz_GUmB5ZoVLmA8xWdbJxVxU",
|
||||
RefreshToken = "1//04FeDguc19IfgCgYIARAAGAQSNwF-L9Ir8U7wX2seanUzsxXXGgFzOYQqjbtN9O27ZZybbOobZjVAo_4_eFNLMX1ElPKOFVWsrJQ"
|
||||
};
|
||||
|
||||
var applicationName = "Files"; // Use the name of the project in Google Cloud
|
||||
var username = "asbautodrilling@gmail.com"; // Use your email
|
||||
|
||||
var apiCodeFlow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
|
||||
{
|
||||
ClientSecrets = new ClientSecrets
|
||||
{
|
||||
ClientId = "1020584579240-f7amqg35qg7j94ta1ntgitajq27cgh49.apps.googleusercontent.com",
|
||||
ClientSecret = "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"
|
||||
},
|
||||
Scopes = new[] { DriveService.Scope.Drive },
|
||||
DataStore = new FileDataStore(applicationName)
|
||||
});
|
||||
|
||||
var credential = new UserCredential(apiCodeFlow, username, tokenResponse);
|
||||
|
||||
var newService = new DriveService(new BaseClientService.Initializer
|
||||
{
|
||||
HttpClientInitializer = credential,
|
||||
ApplicationName = applicationName
|
||||
});
|
||||
this.service = newService;
|
||||
}
|
||||
|
||||
// public IEnumerable<Google.Apis.Drive.v3.Data.File> GetAllFiles() // get file names
|
||||
// {
|
||||
// var fileList = service.Files.List();
|
||||
// fileList.Fields = "files(id, webViewLink, size)";
|
||||
// //fileList.Q =$"mimeType!='application/vnd.google-apps.folder' and '{folder}' in parents";
|
||||
// //fileList.Fields = "nextPageToken, files(id, name, size, mimeType)";
|
||||
//
|
||||
// var result = new List<Google.Apis.Drive.v3.Data.File>();
|
||||
// string pageToken = null;
|
||||
// do
|
||||
// {
|
||||
// fileList.PageToken = pageToken;
|
||||
// var filesResult = fileList.Execute();
|
||||
// var files = filesResult.Files;
|
||||
// pageToken = filesResult.NextPageToken;
|
||||
// result.AddRange(files);
|
||||
// } while (pageToken != null);
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
|
||||
public string GetFileWebLink(string idFile)
|
||||
{
|
||||
var fileList = service.Files.List();
|
||||
fileList.Fields = "files(id, webViewLink, size)";
|
||||
var filesResult = fileList.Execute();
|
||||
var file = filesResult.Files.FirstOrDefault(f => f.Id == idFile);
|
||||
return file?.WebViewLink ?? string.Empty;
|
||||
}
|
||||
|
||||
// У Гугла почему-то folder это и папка, и файл.
|
||||
public string CreateFolder(string folderName)
|
||||
{
|
||||
var driveFolder = new Google.Apis.Drive.v3.Data.File();
|
||||
driveFolder.Name = folderName;
|
||||
driveFolder.MimeType = "application/vnd.google-apps.folder";
|
||||
//driveFolder.Parents = new string[] { parent };
|
||||
var command = service.Files.Create(driveFolder);
|
||||
var file = command.Execute();
|
||||
return file.Id;
|
||||
}
|
||||
|
||||
public void CreatePublicPermissionForFile(string idFile)
|
||||
{
|
||||
var permission = new Permission() { Type = "anyone", Role = "reader" };
|
||||
var addPermissionRequest = service.Permissions.Create(permission, idFile);
|
||||
addPermissionRequest.Execute();
|
||||
}
|
||||
|
||||
public string UploadFile(Stream file, string fileName, string fileMime, string fileDescription)
|
||||
{
|
||||
var driveFile = new Google.Apis.Drive.v3.Data.File();
|
||||
driveFile.Name = fileName;
|
||||
driveFile.Description = fileDescription;
|
||||
driveFile.MimeType = fileMime;
|
||||
//driveFile.Parents = new [] {folder};
|
||||
|
||||
var request = service.Files.Create(driveFile, file, fileMime);
|
||||
request.Fields = "id";
|
||||
|
||||
var response = request.Upload();
|
||||
if (response.Status != Google.Apis.Upload.UploadStatus.Completed)
|
||||
throw response.Exception;
|
||||
|
||||
return request.ResponseBody.Id;
|
||||
}
|
||||
|
||||
public void DeleteFile(string fileId)
|
||||
{
|
||||
var command = service.Files.Delete(fileId);
|
||||
var result = command.Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// usage example:
|
||||
|
||||
// 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.UploadFileAsync(fileStream, fileInfo.Name, "", "uploaded");
|
||||
// service.CreatePublicPermissionForFileAsync(uploadedFileId);
|
||||
// var webLink = service.GetFileWebLinkAsync(uploadedFileId);
|
||||
// Console.WriteLine(webLink);
|
Loading…
Reference in New Issue
Block a user