S3 can't convert Array into string error #338

Closed
Migoo opened this Issue Oct 22, 2010 · 4 comments

Comments

Projects
None yet
3 participants
@Migoo

Migoo commented Oct 22, 2010

Hi,

I update Paperclip from 2.3.3 to 2.3.4 and I have an issue with S3 uploading. To fix it I have to rollback to 2.3.3.

Here is my the errors:

can't convert Array into String

paperclip (2.3.4) lib/paperclip/storage/s3.rb:131:in `extname'

paperclip (2.3.4) lib/paperclip/storage/s3.rb:131:in `to_file'

app/models/theme.rb:373:in `extract_files_from_zip_file'

@matthutchinson

This comment has been minimized.

Show comment
Hide comment
@matthutchinson

matthutchinson Oct 25, 2010

Here is a patch that I've got to work in the meantime;
def to_file style = default_style
return @queued_for_write[style] if @queued_for_write[style]
filename = path(style)
extname = File.extname(path(style).split(".").last)
basename = File.basename(filename, extname)
file = Tempfile.new(basename)
file.write(AWS::S3::S3Object.value(path(style), bucket_name))
file.rewind
return file
end

Here is a patch that I've got to work in the meantime;
def to_file style = default_style
return @queued_for_write[style] if @queued_for_write[style]
filename = path(style)
extname = File.extname(path(style).split(".").last)
basename = File.basename(filename, extname)
file = Tempfile.new(basename)
file.write(AWS::S3::S3Object.value(path(style), bucket_name))
file.rewind
return file
end

@Migoo

This comment has been minimized.

Show comment
Hide comment
@Migoo

Migoo Oct 26, 2010

Thanks for your answer.

I willl keep paperclip 2.3.3 in production and update it to 2.3.5 with this bug fix.

Regards

Migoo commented Oct 26, 2010

Thanks for your answer.

I willl keep paperclip 2.3.3 in production and update it to 2.3.5 with this bug fix.

Regards

@matthutchinson

This comment has been minimized.

Show comment
Hide comment
@matthutchinson

matthutchinson Oct 26, 2010

Actually this is safer, for the case the file doesn't have an extension

def to_file style = default_style
    return @queued_for_write[style] if @queued_for_write[style]
    filename = path(style)           
    extname  = filename.include?('.') ? File.extname(filename.split(".").last) : ''
    basename = File.basename(filename, extname)
    file = Tempfile.new(basename)
    file.write(AWS::S3::S3Object.value(path(style), bucket_name))
    file.rewind
    return file
  end

Actually this is safer, for the case the file doesn't have an extension

def to_file style = default_style
    return @queued_for_write[style] if @queued_for_write[style]
    filename = path(style)           
    extname  = filename.include?('.') ? File.extname(filename.split(".").last) : ''
    basename = File.basename(filename, extname)
    file = Tempfile.new(basename)
    file.write(AWS::S3::S3Object.value(path(style), bucket_name))
    file.rewind
    return file
  end

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment