diff options
| author | Teddy Wing | 2022-09-20 21:01:03 +0200 |
|---|---|---|
| committer | Teddy Wing | 2022-09-20 21:01:03 +0200 |
| commit | 8b463b2b53fa43270681f8b829f073fd60ab0b7b (patch) | |
| tree | 0673b10acc2baafbafcd1e42f8332b55139dbade | |
| parent | 2cc79c6873dc59b0510045717b0359bc64513fc1 (diff) | |
| download | gdrive-8b463b2b53fa43270681f8b829f073fd60ab0b7b.tar.bz2 | |
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.
| -rw-r--r-- | drive/export.go | 3 |
1 files changed, 3 insertions, 0 deletions
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 |
