This repository has been archived by the owner on May 4, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add public / private option for dropbox apps
add visibility option to readme Readme formating pull extracted classes into their own files
- Loading branch information
1 parent
9f0dec7
commit a0f77a3
Showing
8 changed files
with
98 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require "paperclip/storage/dropbox/private_url_generator" | ||
require "paperclip/storage/dropbox/public_url_generator" | ||
module Paperclip | ||
module Storage | ||
module Dropbox | ||
module GeneratorFactory | ||
def self.build_url_generator(storage, options) | ||
if options[:dropbox_credentials][:access_type] == "app_folder" | ||
PrivateUrlGenerator.new(storage, options) | ||
elsif options[:dropbox_credentials][:access_type] == "dropbox" | ||
PublicUrlGenerator.new(storage, options) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "paperclip/storage/dropbox/url_generator" | ||
module Paperclip | ||
module Storage | ||
module Dropbox | ||
class PrivateUrlGenerator < UrlGenerator | ||
def file_url(style) | ||
@attachment.dropbox_client.media(@attachment.path(style))["url"] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require "paperclip/storage/dropbox/url_generator" | ||
module Paperclip | ||
module Storage | ||
module Dropbox | ||
class PublicUrlGenerator < UrlGenerator | ||
def file_url(style) | ||
url = URI.parse("https://dl.dropboxusercontent.com/u/#{user_id}/") | ||
path = @attachment.path(style) | ||
path = path.match(/^Public\//).post_match | ||
url.merge!(path) | ||
url.to_s | ||
end | ||
end | ||
end | ||
end | ||
end |
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
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