From 7a30d5618f5dc74646960b4aea80d360c1a3c3f5 Mon Sep 17 00:00:00 2001 From: Neil Gehani Date: Thu, 12 Dec 2013 15:15:16 -0800 Subject: [PATCH] Security issue fixed for S3 --- app/controllers/pins_controller.rb | 2 +- lib/tasks/populateimages3.rake | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/pins_controller.rb b/app/controllers/pins_controller.rb index 13c001e..5cb58d4 100644 --- a/app/controllers/pins_controller.rb +++ b/app/controllers/pins_controller.rb @@ -5,7 +5,7 @@ class PinsController < ApplicationController def index # With pagination from will_paginate gem - @pins = Pin.all.order("created_at DESC").page(params[:page]).per_page(20) + @pins = Pin.order("created_at DESC").page(params[:page]).per_page(20) respond_to do |format| format.html # index.html.erb #format.json { render json: @pins } diff --git a/lib/tasks/populateimages3.rake b/lib/tasks/populateimages3.rake index 468896e..1177485 100644 --- a/lib/tasks/populateimages3.rake +++ b/lib/tasks/populateimages3.rake @@ -6,7 +6,13 @@ namespace :db do User.all.each do |user| puts "[DEBUG] uploading images for user #{user.id} of #{User.last.id}" 10.times do |n| - #image = image_remote_url('https://event_sample_images.s3-website-us-east-1.amazonaws.com').sample + #What I want here is perhaps an array that gets the list of file names + #via a wildcard - basically anything.jpg and puts them in an array + #then use the elements of the array and append to the url - .../sample/blah + #and pop from the array until empty + #example - this link works - https://s3.amazonaws.com/event_sample_images/sample/IMG_0537.jpg + #but the link to just the sample directory does not .../sample + #image_url = 'https://s3.amazonaws.com/event_sample_images/sample/*.jpg' #description = %w(cool awesome crazy wow adorbs incredible).sample #user.pins.create!(image: image, description: description) end