Skip to content

Instantly share code, notes, and snippets.

@AJLfleos
Last active September 22, 2024 18:06
Show Gist options
  • Save AJLfleos/3d0ab93d342a7cb9bf58a546cdeccb46 to your computer and use it in GitHub Desktop.
Save AJLfleos/3d0ab93d342a7cb9bf58a546cdeccb46 to your computer and use it in GitHub Desktop.
test object upload from fog client in cloud_controller_ng on a S3 compatible bucket using `aws` provider
require 'fog/aws'
require 'vcap/digester'
require 'cloud_controller/blobstore/fog/fog_client'
require 'fog/aws/models/storage/files'
require 'fog/aws/models/storage/directories'
require 'mailjet'
module CloudController
module Blobstore
class Test
def initialize()
fog_connection = {}
fog_connection[:provider] = 'aws'
fog_connection[:aws_access_key_id] = '3YOH7HSNJSEOUZMGNOQ7'
fog_connection[:aws_secret_access_key] = 'kLyF4GKxi8qk7fQIaJrvW6ep9FoxzObn1aZBPkKK'
fog_connection[:host] = 'objectstorage.test_region.test'
fog_connection[:path_style] = true
fog_connection[:aws_signature_version] = 4
fog_connection[:region] = "test_region",
fog_connection[:connection_options] = {
ssl_verify_peer: false
}
@bucket_name = 'rirsr-cf-buildpack-bucket'
print "create client connection\n"
@client = CloudController::Blobstore::FogClient.new(
connection_config: fog_connection,
directory_key: @bucket_name
)
@conn = Fog::Storage.new(
fog_connection
)
@directory = @conn.directories.new(key: @bucket_name)
end
def small_tests
@client.cp_to_blobstore('/root/test.zip', '82065e40-3ef0-4463-b077-fae19e2d2ec3_5c24ac517c5c79be2f2e8b48933c5dbeff664b1024f34df5110af9bc0ec3273d')
end
end
end
end
tester = CloudController::Blobstore::Test.new
tester.small_tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment