From 24a84d65235e9cc28ab904a19f801aefe0d952e5 Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 1 Nov 2018 11:27:16 +0300 Subject: [PATCH] Added $date placeholder support to S3 (fixes #595) --- docs/s3.adoc | 1 + upload/s3.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/s3.adoc b/docs/s3.adoc index 05dc6302..ec7944d6 100644 --- a/docs/s3.adoc +++ b/docs/s3.adoc @@ -18,6 +18,7 @@ By default uploaded file name is preserved, i.e. S3 path is `/.log` | $browserName | Replaced by Selenium browser name capability value | $browserVersion | Replaced by Selenium browser version capability value +| $date | Replaced by current date, e.g. `2018-11-01` | $fileName | Replaced by source file name | $fileExtension | Replaced by source file extension | $fileType | Replaced by `log` for log files and `video` for video files diff --git a/upload/s3.go b/upload/s3.go index fff926ae..a8f489fb 100644 --- a/upload/s3.go +++ b/upload/s3.go @@ -14,6 +14,7 @@ import ( "os" "path/filepath" "strings" + "time" ) func init() { @@ -104,6 +105,7 @@ func GetS3Key(keyPattern string, input *UploadRequest) string { key = strings.Replace(key, "$quota", strings.ToLower(sess.Quota), -1) key = strings.Replace(key, "$sessionId", strings.ToLower(input.SessionId), -1) key = strings.Replace(key, "$fileType", strings.ToLower(input.Type), -1) + key = strings.Replace(key, "$date", time.Now().Format("2006-01-02"), -1) key = strings.Replace(key, " ", "-", -1) return key }