Skip to content

Commit

Permalink
Code cleanup. Successfully working with Cyberduck now.
Browse files Browse the repository at this point in the history
  • Loading branch information
razerbeans committed Jan 5, 2011
1 parent f15c8e0 commit aa6d8a4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/boardwalk/control_routes.rb
Expand Up @@ -70,7 +70,7 @@
end
tempf = Tempfile.new("#{slot.file_name}")
tempf.puts slot.bit.data
send_file(tempf.path, {:disposition => 'attachment', :filename => slot.file_name, :type => slot.bit_type})
send_file(tempf.path, {:disposition => 'attachment', :filename => slot.file_name, :type => slot.bit_type, :length => slot.bit_size})
tempf.close!
status 200
end
Expand Down
2 changes: 1 addition & 1 deletion lib/boardwalk/helpers.rb
Expand Up @@ -14,7 +14,7 @@ def aws_authenticate
@amz.sort.each do |k, v|
canonical[-1,0] = "x-amz-#{k}:#{v}"
end
# puts "Environment info: " + @env.inspect
# puts "\e[1;32mEnvironment info:\e[0m" + @env.inspect
@user = User.first(:conditions => {:s3key => key})
if @user and secret != hmac_sha1(@user.s3secret, canonical.map{|v|v.to_s.strip} * "\n")
raise BadAuthentication
Expand Down
9 changes: 3 additions & 6 deletions lib/boardwalk/s3_routes.rb
Expand Up @@ -69,8 +69,9 @@
aws_authenticate
bucket = @user.buckets.to_enum.find{|b| b.name == params[:captures][0]}
slot = bucket.slots.to_enum.find{|s| s.file_name == params[:captures][1]}
# puts "\e[1;32mBit size:\e[0m " + slot.bit_size.to_s
aws_only_can_read slot

since = Time.httpdate(request.env['HTTP_IF_MODIFIED_SINCE']) rescue nil
if since && (slot.bit.upload_date) <= since
raise NotModified
Expand All @@ -82,14 +83,10 @@
if request.env['HTTP_IF_NONE_MATCH'] && (slot.md5 == request.env['HTTP_IF_NONE_MATCH'])
raise NotModified
end
if request.env['HTTP_RANGE']
raise NotImplemented
end
tempf = Tempfile.new("#{slot.file_name}")
tempf.puts slot.bit.data
send_file(tempf.path, {:disposition => 'attachment', :filename => slot.file_name, :type => slot.bit_type})
send_file(tempf.path, {:disposition => 'attachment', :filename => slot.file_name, :type => slot.bit_type, :length => slot.bit_size})
tempf.close!
status 200
end

get %r{/([^\/]+)/?} do |e|
Expand Down

0 comments on commit aa6d8a4

Please sign in to comment.