pomf.rb 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/pomf.rb +45 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16e8aa792d15527ded4d3df76656b409bea21d19
|
4
|
+
data.tar.gz: a967730df61a175720eaa538bf4d0af993cd8764
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 295297525967232b285d19fc9d75b191cb86dc623a7f1aaa6a3412f2805bb7ddbdad6a0f69808e9268aac6107c0dd05da34709ffc47215c39ac4da39592b08af
|
7
|
+
data.tar.gz: 3d377d20649ae2153593b6c7425a1c848f18335de8193af00c2e9231488900e7d39a64fc687b68b62499b5082cd51acb625e9b3295446ac7a52e71009952d4a9
|
data/lib/pomf.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Author: Erisa Komuro (Seriel), forked from Euank's repo
|
3
|
+
# License: Public Domain
|
4
|
+
|
5
|
+
|
6
|
+
require 'tempfile'
|
7
|
+
require 'json'
|
8
|
+
require 'net/http'
|
9
|
+
require 'net/https'
|
10
|
+
use_curl = false
|
11
|
+
begin
|
12
|
+
require 'net/http/post/multipart'
|
13
|
+
rescue LoadError
|
14
|
+
use_curl = true
|
15
|
+
end
|
16
|
+
|
17
|
+
module Pomf
|
18
|
+
def self.upload_file(filepath, upload = 'https://pomf.cat/upload.php', result = 'https://a.pomf.cat/')
|
19
|
+
mime = nil
|
20
|
+
file = File.new(filepath)
|
21
|
+
url = URI.parse(upload)
|
22
|
+
res = nil
|
23
|
+
File.open(file.path) do |toup|
|
24
|
+
req = Net::HTTP::Post::Multipart.new url.path,
|
25
|
+
"files[]" => UploadIO.new(toup, mime, File.basename(toup.path))
|
26
|
+
res = Net::HTTP.start(url.host,url.port, :use_ssl => url.scheme == 'https') do |http|
|
27
|
+
http.request(req)
|
28
|
+
end
|
29
|
+
res = res.body rescue res
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
res = JSON.parse(res)
|
34
|
+
rescue
|
35
|
+
puts "Unable to parse json response: Got response #{res}"
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
|
39
|
+
if res["success"]
|
40
|
+
return "#{res["files"].first["url"]}"
|
41
|
+
else
|
42
|
+
raise "Error: " + res.to_s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pomf.rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erisa Komuro (Seriel)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Simple Ruby library for uploading files to pomf.
|
14
|
+
email: seriel@fl0.co
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/pomf.rb
|
20
|
+
homepage: https://github.com/Seriell/pomf.rb
|
21
|
+
licenses:
|
22
|
+
- Unlicense
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.1'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.12
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: pomf.rb
|
44
|
+
test_files: []
|