Normalized Id across all files and moved mimetypes into a shared place
This commit is contained in:
@@ -14,9 +14,9 @@ internal class DriveFileContentSourceEntry(SourceProvider provider, string paren
|
||||
{
|
||||
var service = provider.ApiHelper.GetDriveService();
|
||||
|
||||
if (IsGoogleDoc(file.MimeType))
|
||||
if (GoogleMimeTypes.IsGoogleDoc(file.MimeType))
|
||||
{
|
||||
var exportMimeType = GetExportMimeType(file.MimeType);
|
||||
var exportMimeType = GoogleMimeTypes.GetExportMimeType(file.MimeType);
|
||||
var request = service.Files.Export(file.Id, exportMimeType);
|
||||
var stream = new MemoryStream();
|
||||
await request.DownloadAsync(stream, cancellationToken);
|
||||
@@ -33,25 +33,6 @@ internal class DriveFileContentSourceEntry(SourceProvider provider, string paren
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsGoogleDoc(string mimeType)
|
||||
{
|
||||
return mimeType.StartsWith("application/vnd.google-apps.") &&
|
||||
mimeType != "application/vnd.google-apps.folder" &&
|
||||
mimeType != "application/vnd.google-apps.shortcut";
|
||||
}
|
||||
|
||||
private static string GetExportMimeType(string mimeType)
|
||||
{
|
||||
return mimeType switch
|
||||
{
|
||||
"application/vnd.google-apps.document" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"application/vnd.google-apps.spreadsheet" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"application/vnd.google-apps.presentation" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
"application/vnd.google-apps.script" => "application/vnd.google-apps.script+json",
|
||||
_ => "application/pdf"
|
||||
};
|
||||
}
|
||||
|
||||
public override Task<Dictionary<string, string?>> GetMinorMetadata(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(new Dictionary<string, string?>
|
||||
@@ -59,7 +40,7 @@ internal class DriveFileContentSourceEntry(SourceProvider provider, string paren
|
||||
{ "gsuite:v", "1" },
|
||||
{ "gsuite:Type", SourceItemType.DriveFileContent.ToString() },
|
||||
{ "gsuite:Name", "content" },
|
||||
{ "gsuite:id", file.Id },
|
||||
{ "gsuite:Id", file.Id },
|
||||
{ "gsuite:MimeType", file.MimeType }
|
||||
}
|
||||
.Where(kv => !string.IsNullOrEmpty(kv.Value))
|
||||
|
||||
Reference in New Issue
Block a user