Skip to content

Instantly share code, notes, and snippets.

@cbeer
Created May 7, 2010 17:48
Show Gist options
  • Save cbeer/393770 to your computer and use it in GitHub Desktop.
Save cbeer/393770 to your computer and use it in GitHub Desktop.
# Ruby/Fedora script to upload a file to a Fedora Commons repository
# Author: Chris Beer
require 'rubygems'
require 'rest_client'
require 'mime/types'
require 'cgi'
rest_uri = 'http://localhost:8080/fedora'
user = 'fedoraUser'
pass = 'fedoraPassword'
file = ARGV[0]
pid = ARGV[1]
dsid = ARGV[2]
label = ARGV[3]
client = RestClient::Resource.new rest_uri + "/objects/" + pid + "/datastreams/" + dsid + "?controlGroup=M&dsLabel=" + CGI::escape(label) + "&checksumType=DISABLED", :user => user, :password => pass
client.post File.read(file), :content_type => MIME::Types.type_for(file).first.to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment