Created
May 7, 2010 17:48
-
-
Save cbeer/393770 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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