fake-s3 icon indicating copy to clipboard operation
fake-s3 copied to clipboard

Running FakeS3 on Windows does not allow colons (and other special characters) in key name

Open code-the-pizza opened this issue 8 years ago • 0 comments

The filestore store uses the keyname directly as a filename, so on Windows a failure occurs when storing a key with a colon in it.

Here is my work around:

require 'uri-handler'

# Class that encodes the object name, so that colons in the object name do not cause a failure.
class UrlEncodingFileStore < FakeS3::FileStore

  def get_object(bucket,object_name, request)
    object_name = object_name.to_uri
    return super(bucket, object_name, request)
  end

  def copy_object(src_bucket_name, src_name, dst_bucket_name, dst_name, request)
    src_name = src_name.to_uri
    dst_name = dst_name.to_uri
    
    return super(src_bucket_name, src_name, dst_bucket_name, dst_name, request)
  end

  def do_store_object(bucket, object_name, filedata, request)
    object_name = object_name.to_uri
    return super(bucket, object_name, filedata, request)
  end

  def combine_object_parts(bucket, upload_id, object_name, parts, request)
    object_name = object_name.to_uri
    return super(bucket, upload_id, object_name, parts, request)
  end

  def delete_object(bucket,object_name,request)
    object_name = object_name.to_uri
    return super(bucket,object_name,request)
  end

end

code-the-pizza avatar Nov 11 '16 14:11 code-the-pizza