lib/eco/api/session.rb in eco-helpers-1.1.3 vs lib/eco/api/session.rb in eco-helpers-1.1.4
- old
+ new
@@ -206,11 +206,16 @@
end
# Sends an email
# @see Eco::API::Common::Session::Mailer#mail
def mail(**kargs)
- mailer.mail(**kargs)
+ if mailer?
+ mailer.mail(**kargs)
+ else
+ logger.error("You are trying to use the mailer, but it's not configured")
+ nil
+ end
end
# Uploads content into a file, a file or a directory to S3
# @see Eco::API::Common::Session::S3Uploader#upload
# @see Eco::API::Common::Session::S3Uploader#upload_file
@@ -220,22 +225,27 @@
# @param directory [String] name of source directory to be uploaded
# @param recurse [Boolean] used with `directory`: deepen in the folder structure? (`false`: default)
# @param link [Boolean] **return** _link(s)_ (`true`) or _path(s)_ (`false`: default)
# @return [String, Array<String>] either paths to S3 objects if `link` is `false`, or _link_ otherwise
def s3upload(content: nil, file: nil, directory: nil, recurse: false, link: false)
- if content == :target
- path = self.do.s3upload_targets
- elsif content && file
- path = s3uploader.upload(file, content)
- elsif file
- path = s3uploader.upload_file(file)
- elsif directory
- path = s3uploader.upload_directory(directory, recurse: recurse)
+ if s3uploader?
+ if content == :target
+ path = self.do.s3upload_targets
+ elsif content && file
+ path = s3uploader.upload(file, content)
+ elsif file
+ path = s3uploader.upload_file(file)
+ elsif directory
+ path = s3uploader.upload_directory(directory, recurse: recurse)
+ else
+ logger.error("To use Session.s3upload, you must specify either directory, file or content and file name")
+ end
+ return path unless link
+ s3uploader.link(path)
else
- logger.error("To use Session.s3upload, you must specify either directory, file or content and file name")
+ logger.error("You are trying to use S3 uploader, but it's not configured")
+ nil
end
- return path unless link
- s3uploader.link(path)
end
private
# Helper to state the abilities that a person should have with given their usergroups