Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

May not be handling hash properly? #35

Open
hoopsho opened this issue Aug 8, 2011 · 14 comments
Open

May not be handling hash properly? #35

hoopsho opened this issue Aug 8, 2011 · 14 comments
Assignees

Comments

@hoopsho
Copy link

hoopsho commented Aug 8, 2011

Using the following values for that attachment:

...
:path => "/:view_key/:style/:hash",
:use_timestamp => false,
:hash_secret => "hash.secret",
:hash_data => ":class/:attachment/:id/:style/:updated_at"
...

The process works, and the styles are generated on S3, but the hash is different. The image from paperclip/rails perspective thinks that it has a different path with a different hash than what is actually out on S3.

S3:
/l3n08oq9wqo18wgq8454/post/d3610c38d4d3c9efc8fa3ad92bbebe0be2236d49

Rails/paperclip:
/l3n08oq9wqo18wgq8454/post/75953d644e3684c584d25e401ee250b0ce36ca78

If I remove the hashed path requirements, the code works great and happily places the files out on S3 with the default pathing.

Thoughts as to what may be the problem with using a hashed path? Is it that the code is not interrogating the hash_data and hash_secret when creating the file out on s3? or perhaps a mismatch in using the updated_at field?

Thanks,
Chris.

@Bertg
Copy link
Contributor

Bertg commented Aug 8, 2011

Hey,

This could indeed be related to a date attribute being updated during the background processing. Maybe it also could have something to do with the url_with_processed method (https://github.com/jstorimer/delayed_paperclip/blob/master/lib/delayed_paperclip.rb#L120)

Could you verify any of these cases? I don't have much time this week to investigate, but could make some time if I know what to fix...

@hoopsho
Copy link
Author

hoopsho commented Aug 12, 2011

I cannot figure it out. There has to be two updates happening to the model, one of them prior to uploading to S3 and hte other prior to saving the record the second time in the DB.

@Bertg
Copy link
Contributor

Bertg commented Aug 25, 2011

Can you have a look at this issue: #34

It describes issues with the url method, and how this can be fixed.

I'd like to know if reverting to the original url method works for you.

@hoopsho
Copy link
Author

hoopsho commented Aug 25, 2011

My default config:
:path => "/:view_key/:style/:hash"
:use_timestamp => false
:hash_secret => SECRET_HASH
:hash_data => ":class/:attachment/:id/:style/:updated_at"

I tried the following combinations:

url(:post)
url(:post, true)
url_with_processing(:post)
url_with_processing(:post, true)
url_without_processing(:post)
url_without_processing(:post, true)

all of which provide a different url than what is actually uploaded to S3 during the DJ process.

So maybe i am not making the right changes, but it does not seem to change anything.

@Bertg
Copy link
Contributor

Bertg commented Sep 18, 2011

Hi,

I was wondering if this problem still exists in the latest git HEAD version?

If not, could you try to use the ":url_with_processing => false" option, and see if that fixes your issue.

@hoopsho
Copy link
Author

hoopsho commented Sep 19, 2011

Hey,

Yea, still the same issue. I tried pulling in your repo via git and configuring the image params with url_with_processing set to false... same problem as before. the image gets placed in a different location than the URL references.

@ghost ghost assigned jstorimer Sep 19, 2011
@Bertg
Copy link
Contributor

Bertg commented Sep 19, 2011

Sorry, but with the given information I can not help you out.

I've assigned this to jstorimer, hoping he can help you with this.

@hoopsho
Copy link
Author

hoopsho commented Sep 19, 2011

I will gladly provide more information, just let me know what more is needed.

@dalssoft
Copy link

dalssoft commented Dec 5, 2011

The same problem here, using local storage in Dev.

Without /:hash/ it works fine.

Paperclip::Attachment.default_options.update({
  :url => "/system/images/:class/:id/:attachment/:style/:hash/:basename"
})

@dmitry
Copy link

dmitry commented Apr 27, 2015

Problem is still exists. The reason of it that worker is triggering save on model, and it updates updated_at field. :updated_at and :hash interpolators are related from the model updated_at attribute value.

@dmitry
Copy link

dmitry commented Apr 27, 2015

Fixed with hacking into the activerecord callback:

  before_save do
    if photo.job_is_processing
      write_attribute(:photo_updated_at, photo_updated_at_was)
    end
  end

@coneybeare
Copy link

For me the fix was similar. I have the <attachment>_processing column setup

before_save do
  avatar_updated_at = avatar_updated_at_was if avatar_processing
end

@abrbhat
Copy link

abrbhat commented Feb 17, 2016

Having the same issue. dmitry's hack working good for now.
Edit: Actually dmitry's hack is only keeping the filename in database same. The filename of the actual file is still different.

@dmitry
Copy link

dmitry commented Feb 17, 2016

@abrbhat I've switched to https://github.com/janko-m/shrine, more modular (easier to follow the code) and predictable behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants