Skip to content

Instantly share code, notes, and snippets.

View fleveque's full-sized avatar

Francesc Leveque fleveque

  • Stuart
  • Cubelles, Garraf, Barcelona
View GitHub Profile
fleveque / folders.rb
Created February 4, 2016 10:13
Returns an array of subfolders for a given path on S3, with aws-sdk (ruby)
# Returns an array of subfolders for a given path
def folders(path = '/')
objs = []
next_marker = nil
loop do
response =
bucket: 'bucket',
delimiter: "/",
encoding_type: "url",
marker: next_marker,
fleveque / s3_folder_upload.rb
Last active November 21, 2022 17:22
Upload folder to S3 recursively with ruby, multi threads and aws-sdk v2 gem, based on
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket, :include_folder
attr_accessor :files
# Initialize the upload class
fleveque / migrate_s3.rake
Last active November 2, 2015 14:52
rake task to migrate paperclip attachments to Amazon S3 using aws-sdk v1
namespace :attachments do
task migrate_to_s3: :environment do
require 'aws-sdk'
# Define Paperclip models (change with your own)
models = [
[Model1, :data],
[Model2, :logo]
fleveque / gist:a9b21ebdbe6f24299430
Created October 29, 2014 09:22
Ruby version and gemsets with rvm inside bash script
source "$HOME/.rvm/scripts/rvm" &&
rvm use 2.1.2
# Use bash, not sh on first line