Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added support to cloudapp for uploading stdin #658

Closed
wants to merge 1 commit into from

4 participants

Hugo Wetterberg Sorin Ionescu Robby Russell Matthew McCullough
Hugo Wetterberg

Example usage:

echo "Hello" | cloudapp - hello.txt

Sorin Ionescu

Please send this patch to the original author of cloudapp.rb.

Robby Russell

Bringing @matthewmccullough into the discussion...

Sorin Ionescu

@robbyrussell I believe @holman is the original author.

I don't think this makes much sense as a plugin. It's an alias to a script. cloudapp.rb makes more sense being dropped in one's personal bin directory.

Matthew McCullough

I agree that it is centered around an alias and I could add some completions. But https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/yum/yum.plugin.zsh is purely aliases. I would like to know what the threshold is for a plugin if others are just aliases. Let me know and we'll proceed accordingly.

Sorin Ionescu

Many aliases are fine. In this case, it's just one alias to a script that should be in a /bin directory in your $PATH with many other scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2011
  1. Hugo Wetterberg
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 2 deletions.
  1. +14 −2 plugins/cloudapp/cloudapp.rb
16 plugins/cloudapp/cloudapp.rb
View
@@ -45,16 +45,28 @@ def ok? ; true end
if ARGV[0].nil?
puts "You need to specify a file to upload."
exit!(1)
+elsif ARGV[0] == '-'
+ if ARGV[1].nil?
+ puts "You need to specify a filename for the input stream."
+ puts "Example usage: echo \"Hello\" | cloudapp - hello.txt"
+ exit!(1)
+ end
+ file = "/tmp/#{ARGV[1]}"
+ f = open(file, File::CREAT | File::WRONLY | File::BINARY)
+ f.write STDIN.read
+ f.close
+else
+ file = ARGV[0]
end
CloudApp.authenticate(email,password)
-url = CloudApp::Item.create(:upload, {:file => ARGV[0]}).url
+url = CloudApp::Item.create(:upload, {:file => file}).url
# Say it for good measure.
puts "Uploaded to #{url}."
# Get the embed link.
-url = "#{url}/#{ARGV[0].split('/').last}"
+url = "#{url}/#{file.split('/').last}"
# Copy it to your (Mac's) clipboard.
`echo '#{url}' | tr -d "\n" | pbcopy`
Something went wrong with that request. Please try again.