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

Original filename is not available #49

Open
jfrolich opened this issue Oct 20, 2016 · 3 comments
Open

Original filename is not available #49

jfrolich opened this issue Oct 20, 2016 · 3 comments

Comments

@jfrolich
Copy link

jfrolich commented Oct 20, 2016

When I save my file under a different name as the original file name, and I want to use the content_disposition header to serve the right file name, I can do that using s3_object_headers():

  def s3_object_headers(version, {file, scope}) do
    [
      content_disposition: "attachment; filename=#{scope.file}"
    ]
  end

However we have one problem. The filename is not yet available in the scope, and file also does not provide the original file name. I assume this is a bug (can we pass an up to date scope?), and otherwise how can we access the original filename?

@stavro
Copy link
Owner

stavro commented Oct 20, 2016

I believe file should have the original filename. What does it have instead? Can you show a printout of what you're seeing for file?

@jfrolich
Copy link
Author

jfrolich commented Oct 21, 2016

I set a storage filename for the version as below, so file_name gives me that.

  def filename(version, {file, scope}) do
    version
  end

@martinos
Copy link

I think that this would be great in the case that we want the preserve the original filename. S3 doesn't permit all utf-8 characters in the object key (http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html). So some file names are not supported by arc_ecto, forcing us to generate a key that is different from the file name.

If we want to keep the original filename, it could be done by adding the content_disposition header with the old filename. However the file that we get in the s3_object_headers function is the key and the the original filename.

Here is the file that I get in the filename function:

%Arc.File{binary: nil, file_name: "file with spaces.pdf",
 path: "/var/folders/3d/0bcszqq14k565g0sqxghlmcm0000gp/T//plug-1504/multipart-147189-189235-5"}

And here is the file in the s3_object_headers function.

%Arc.File{binary: nil, file_name: "filewithspaces.pdf",
 path: "/var/folders/3d/0bcszqq14k565g0sqxghlmcm0000gp/T//plug-1504/multipart-147189-189235-5"}

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

3 participants