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

Rename images when converting formats #403

Closed
wants to merge 1 commit into from
Closed

Rename images when converting formats #403

wants to merge 1 commit into from

Conversation

jcarlson
Copy link
Contributor

This should help with situations where a file has multiple versions, and at least one of the versions is of a different format than the master version. This scenario is documented in issue #378 as well as in issue #284 (and possibly others).

Simply pass :rename => true to the existing convert helper method, and the file will be renamed as well as converted. Existing functionality is preserved, i.e., the default is to not rename the image.

This should help with situations where a file has multiple versions, and at least one of the versions is of a different format than the master version. This scenario is documented in issue #378 as well as in issue #284 (and possibly others).
@jcarlson
Copy link
Contributor Author

Well... hrm... while this patch does what it says it does, the store! process is ignoring the filename as it is in the cache and generating what it thinks the final name should be, which is based off the original, master image. So my patch works, I guess it's just... incomplete.

@jcarlson
Copy link
Contributor Author

I don't see any way around the limitation I'm trying to resolve, i.e., that versions may be of a different MIME-type than the master. Since no information about the versions are stored in the database, there's no way to know what the format of the version is without writing a mutator method on the version itself.

Unfortunately, that makes the patch here pretty useless... oh well... I thought I was on to something.

@jcarlson jcarlson closed this Jul 17, 2011
@jcarlson jcarlson reopened this Jul 17, 2011
@jcarlson jcarlson closed this Jul 17, 2011
@jnicklas
Copy link
Member

I'd really like this functionality, but I haven't yet come up with a good way of implementing it :(

@d11wtq
Copy link

d11wtq commented Aug 30, 2011

I need this too. We're porting from a legacy PHP application that has ~700,000 uploads stored in Amazon S3. I'm currently running a migration that is set to take 45 hours o_O

Anyway, an approach I had thought of, to account for using a different file extension for the version, is to use a method in the uploader to return the filename for the version (#version_filename(version_name) ?). The default implementation of this just returns the version name prefixed onto the main filename, but you could override it to return some other name (i.e. with a different extension).

@d11wtq
Copy link

d11wtq commented Aug 30, 2011

Sorry, ignore my comment. I see this was already solved: #378

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

Successfully merging this pull request may close these issues.

3 participants