paperclip-google-drive 0.3.1 → 0.3.2
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 +4 -4
- data/README.md +10 -3
- data/lib/paperclip/storage/google_drive.rb +10 -2
- data/lib/paperclip/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d485865dd71ce11f5d063479d008aa4d74139663
         | 
| 4 | 
            +
              data.tar.gz: fd200560af8eced312efbbb333491014850fe923
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2c3cd032542c05a0b14fd562a49ad06a019f0f4fdb6c792cdf417463ba646864216c3c58d558ac5ec351f5a581838e3e9855842c70360bec3697be24e1609662
         | 
| 7 | 
            +
              data.tar.gz: ea829ce3a22b96546a2aafab8f33963e086e614a6a6766f0797602a3d4a50b32dbdf303d86040fe02ce8e3ca3924bd0ed92423a14776fae5a970f207894e350c
         | 
    
        data/README.md
    CHANGED
    
    | @@ -79,6 +79,7 @@ This is a hash containing any of the following options: | |
| 79 79 | 
             
             - `:application_name` - is the name that you set for the application credentials on Google console.
         | 
| 80 80 |  | 
| 81 81 | 
             
            The :path option should be a block that returns a path that the uploaded file should be saved to. The block yields the attachment style and is executed in the scope of the model instance. For example:
         | 
| 82 | 
            +
             | 
| 82 83 | 
             
            ```ruby
         | 
| 83 84 | 
             
            class Product < ActiveRecord::Base
         | 
| 84 85 | 
             
              has_attached_file :photo,
         | 
| @@ -93,18 +94,24 @@ end | |
| 93 94 | 
             
            ```
         | 
| 94 95 | 
             
            For example, a new product is created with the ID of 14, and a some_photo.jpg as its photo. The following files would be saved to the Google Drive:
         | 
| 95 96 |  | 
| 97 | 
            +
            ```
         | 
| 96 98 | 
             
            Public/14_some_photo.jpg
         | 
| 97 99 | 
             
            Public/14_some_photo_medium.jpg
         | 
| 100 | 
            +
            ```
         | 
| 98 101 |  | 
| 99 102 | 
             
            The another file is called some_photo_medium.jpg because style names (other than original) will always be appended to the filenames, for better management.
         | 
| 100 103 |  | 
| 101 | 
            -
            Also, you can use the resize feature provided by GDrive API, you only have to pass as parameter in the url params the option `: | 
| 104 | 
            +
            Also, you can use the resize feature provided by GDrive API, you only have to pass as parameter in the url params the option `:custom_thumb` and `:width`, as follows:
         | 
| 102 105 |  | 
| 103 106 | 
             
            ```ruby
         | 
| 104 | 
            -
              some_product.photo.url(: | 
| 107 | 
            +
              some_product.photo.url(:custom_thumb, width: 500)
         | 
| 105 108 | 
             
            ```
         | 
| 106 109 |  | 
| 107 | 
            -
            ##  | 
| 110 | 
            +
            ## Issues
         | 
| 111 | 
            +
             | 
| 112 | 
            +
            ### No images Issues (PDF, CSV, etc)
         | 
| 113 | 
            +
             | 
| 114 | 
            +
            I still working on retrieve the raw files, I would like to get the files as `thumbnail_link` file attribute does, but it is not that easy, because Google Drive API has some retrictions. Therefore, all non images files are shown in Google Drive viwer.
         | 
| 108 115 |  | 
| 109 116 | 
             
            ## Useful links
         | 
| 110 117 |  | 
| @@ -142,9 +142,12 @@ module Paperclip | |
| 142 142 | 
             
                  # @return [ String ] with url
         | 
| 143 143 | 
             
                  def public_url_for(title)
         | 
| 144 144 | 
             
                    metadata_or_default_img_from(title) do |metadata|
         | 
| 145 | 
            -
                      # TODO: fix permission issues on the view with this command
         | 
| 146 145 | 
             
                      # effective_url_from(metadata.web_content_link)
         | 
| 147 | 
            -
                       | 
| 146 | 
            +
                      if content_type =~ /image/
         | 
| 147 | 
            +
                        custom_thumbnail_image_for(metadata.thumbnail_link, 1000)
         | 
| 148 | 
            +
                      else
         | 
| 149 | 
            +
                        metadata.web_view_link
         | 
| 150 | 
            +
                      end
         | 
| 148 151 | 
             
                    end
         | 
| 149 152 | 
             
                  end
         | 
| 150 153 |  | 
| @@ -169,6 +172,10 @@ module Paperclip | |
| 169 172 | 
             
                    "#{ file_url }=s#{ custom_width }"
         | 
| 170 173 | 
             
                  end
         | 
| 171 174 |  | 
| 175 | 
            +
                  # TOO SLOW and PERMISSIONS ISSUES
         | 
| 176 | 
            +
                  # Seems that the retrieved file url is only visible for the
         | 
| 177 | 
            +
                  # user which is owner and is currently log in GDrive.
         | 
| 178 | 
            +
                  #
         | 
| 172 179 | 
             
                  # Gets the effective url from the web content link
         | 
| 173 180 | 
             
                  # These are a series of steps to hack the way that GDrive API
         | 
| 174 181 | 
             
                  # handle its urls. It consists in catch a Google::Apis::RedirectError error
         | 
| @@ -223,6 +230,7 @@ module Paperclip | |
| 223 230 | 
             
                    raise 'the file name was not retrieved' if metadata.name.nil?
         | 
| 224 231 | 
             
                    raise 'the file thumbnail_link was not retrieved' if metadata.thumbnail_link.nil?
         | 
| 225 232 | 
             
                    raise 'the file web_content_link was not retrieved' if metadata.web_content_link.nil?
         | 
| 233 | 
            +
                    raise 'the file web_view_link was not retrieved' if metadata.web_view_link.nil?
         | 
| 226 234 | 
             
                    raise 'the file trashed was not retrieved' if metadata.trashed.nil?
         | 
| 227 235 | 
             
                  end
         | 
| 228 236 |  | 
    
        data/lib/paperclip/version.rb
    CHANGED