lib/pushfile/upload.rb in pushfile-0.1.1 vs lib/pushfile/upload.rb in pushfile-0.1.2
- old
+ new
@@ -49,9 +49,13 @@
end
# Create upload
def create
@file = @data.is_a?(String) ? File.open(@data) : @data[:tempfile]
+
+ # Return error if no file
+ return (@status = {:error => 'upload_file_not_found'}) unless @file
+
@name = filename(@data.is_a?(String) ? @data : @data[:filename])
# Check if it's more than max or return error
return (@status = {:error => 'upload_file_size_is_too_big'}) if @max and @file.size > @max