flickrie 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/flickrie/upload_client.rb +33 -7
- data/lib/flickrie/version.rb +1 -1
- metadata +9 -9
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -247,7 +247,7 @@ basis of this gem.
|
|
247
247
|
|
248
248
|
## Changelog
|
249
249
|
|
250
|
-
You can see the changelog [here](
|
250
|
+
You can see the changelog [here](https://github.com/janko-m/flickrie/blob/master/CHANGELOG.md).
|
251
251
|
|
252
252
|
## License
|
253
253
|
|
@@ -39,13 +39,16 @@ module Flickrie
|
|
39
39
|
class UploadClient < Faraday::Connection
|
40
40
|
def upload(media, params = {})
|
41
41
|
media_file = get_file(media, params[:mime_type])
|
42
|
-
|
42
|
+
media_title = get_title(media)
|
43
|
+
post "upload", {:photo => media_file,
|
44
|
+
:title => media_title}.merge(params)
|
43
45
|
end
|
44
46
|
|
45
47
|
def replace(media, media_id, params = {})
|
46
|
-
media_file = get_file(media)
|
48
|
+
media_file = get_file(media, params[:mime_type])
|
49
|
+
media_title = get_title(media)
|
47
50
|
post "replace", {:photo => media_file,
|
48
|
-
|
51
|
+
:photo_id => media_id, :title => media_title}.merge(params)
|
49
52
|
end
|
50
53
|
|
51
54
|
private
|
@@ -70,11 +73,21 @@ module Flickrie
|
|
70
73
|
}.freeze
|
71
74
|
|
72
75
|
def get_file(object, mime_type = nil)
|
73
|
-
if object.
|
74
|
-
|
75
|
-
|
76
|
-
|
76
|
+
if object.class.name == "String"
|
77
|
+
# file path
|
78
|
+
file_path = object
|
79
|
+
mime_type ||= get_mime_type(file_path)
|
80
|
+
elsif object.class.name == "ActionDispatch::Http::UploadedFile"
|
81
|
+
# Rails
|
82
|
+
file_path = object.tempfile
|
83
|
+
mime_type ||= object.content_type
|
84
|
+
elsif object.class.name == "Hash"
|
85
|
+
# Sinatra
|
86
|
+
file_path = object[:tempfile].path
|
87
|
+
mime_type ||= object[:type]
|
77
88
|
end
|
89
|
+
|
90
|
+
Faraday::UploadIO.new(file_path, mime_type)
|
78
91
|
end
|
79
92
|
|
80
93
|
def get_mime_type(file_path)
|
@@ -84,5 +97,18 @@ module Flickrie
|
|
84
97
|
rescue NoMethodError
|
85
98
|
raise Error, "Don't know mime type for this extension (#{extension})"
|
86
99
|
end
|
100
|
+
|
101
|
+
def get_title(object)
|
102
|
+
filename =
|
103
|
+
if object.class.name == "String"
|
104
|
+
File.basename(object)
|
105
|
+
elsif object.class.name == "ActionDispatch::Http::UploadedFile"
|
106
|
+
object.original_filename
|
107
|
+
elsif object.class.name == "Hash"
|
108
|
+
object[:filename]
|
109
|
+
end
|
110
|
+
|
111
|
+
filename.match(/\.\w{3,4}$/).pre_match
|
112
|
+
end
|
87
113
|
end
|
88
114
|
end
|
data/lib/flickrie/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flickrie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday_middleware
|
16
|
-
requirement: &
|
16
|
+
requirement: &70287090746520 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70287090746520
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simple_oauth
|
27
|
-
requirement: &
|
27
|
+
requirement: &70287090746080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70287090746080
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: multi_xml
|
38
|
-
requirement: &
|
38
|
+
requirement: &70287090745640 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70287090745640
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
|
-
requirement: &
|
49
|
+
requirement: &70287090745060 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70287090745060
|
58
58
|
description: This gem is a nice wrapper for the Flickr API with an intuitive interface.
|
59
59
|
email:
|
60
60
|
- janko.marohnic@gmail.com
|