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

Download CSV filename error #893

Closed
SarahBaghdadi opened this issue Sep 5, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@SarahBaghdadi
Copy link

commented Sep 5, 2018

Hi all, the "Download CSV" feature generates a filename that doesn't open with my OS. For example I downloaded the file:

20180904-requests-sorts%5Bcreated_at%5D=desc&filters%5Bcompany_id%5D=2&properties%5B0%5D=company&properties%5B1%5D=courses&properties%5B2%5D=coursesNew&properties%5B3%5D=rate&properties%5B4%5D=paymentMethod&properties%5B5%5D=student.current.csv

generates the error:

"Sorry, we couldn't find /Users/A/Downloads/20180904-requests-sorts%5Bcreated_at%5D=desc&filters%5Bcompany_id%5D=2&properties%5B0%5D=company&properties%5B1%5D=courses&properties%5B2%5D=coursesNew&properties%5B3%5D=rate&properties%5B4%5D=paymentMethod&properties%5B5%5D=student.cur. Is it possible it was moved, renamed or deleted?"

The file itself is ok. If I change the filename to something else it opens and works fine. I'm using macOS 10.13.6 with Excel.

I think the error is because of the length of the filename since when I reduce it by a few words it fixes the problem. If the filename was something short like mytablename.csv that would be a lot more legible.

@alexweissman

This comment has been minimized.

Copy link
Member

commented Sep 5, 2018

We need to truncate the generated filenames to 255 characters, or whatever the maximum limit is for common OSes.

@amosfolz

This comment has been minimized.

Copy link
Contributor

commented Mar 24, 2019

One of the difficulties with this is that maximum file name length does not just include the file name, but the length of the directory and any parent directories the file is stored in. For example, on Windows the default download folder is C:\Users\Username\Downloads. Username could be any length up to 20 characters (or more in some environments).

Without a way to know the length of the username or the default download path, I'm making the assumption to keep filename under 150 characters, leaving roughly 100 characters for the default storage path.

I tried to keep it "pretty" by truncating to the nearest "&" before the 150th character, so the filename isn't just cut off at a random point.

amosfolz@02b0fdf

Let me know if this might work!

@lcharette

This comment has been minimized.

Copy link
Member

commented Mar 25, 2019

It's probably why most time you download a file, it's named download 🤕

@amosfolz

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2019

@alexweissman Can you provide any insight on why the file name was originally setup the way it was? I wonder if we can just make it simple and use $filename = "$date-{$this->name}"

@amosfolz

This comment has been minimized.

Copy link
Contributor

commented Mar 30, 2019

Any direction on how to move forward? I'd like to help fix this if I can.

@lcharette

This comment has been minimized.

Copy link
Member

commented Mar 31, 2019

I vote for nameOfTable.cvs

amosfolz added a commit to amosfolz/UserFrosting that referenced this issue Apr 3, 2019

Update Sprunje.php
Fix for userfrosting#893
Should prevent file names from exceeding maximum allowed.

@lcharette lcharette added this to the 4.2.1 milestone Apr 16, 2019

@lcharette lcharette closed this Apr 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.