From 8b463b2b53fa43270681f8b829f073fd60ab0b7b Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 20 Sep 2022 21:01:03 +0200 Subject: drive/export: Replace "/" in file name with "_" When the file name includes a "/" character, the export fails. Replace the character in the file name with a "_" character, replicating the behaviour of the Google Docs web UI. Partially fixes https://github.com/prasmussen/gdrive/issues/120. --- drive/export.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drive/export.go b/drive/export.go index 3fdd45a..a09594e 100644 --- a/drive/export.go +++ b/drive/export.go @@ -5,6 +5,7 @@ import ( "io" "mime" "os" + "strings" ) var DefaultExportMime = map[string]string{ @@ -102,6 +103,8 @@ func getExportMime(userMime, fileMime string) (string, error) { } func getExportFilename(name, mimeType string) string { + name = strings.ReplaceAll(name, "/", "_") + extensions, err := mime.ExtensionsByType(mimeType) if err != nil || len(extensions) == 0 { return name -- cgit v1.2.3