Comments (10)
Hey there!
Finally had time to take another look at this. It seems that the characters that cause paperclip to fail (Laravel 5.8 + Postgres + S3)
The characters that are causing us to fail (without thinking about stapler, just with a fresh paperclip install are: +
, ?
, and "
Upon uploading a file, say +.png, the result returned is somepath/+.png
. This fails, however checking somepath/%2B.png
works fine.
Any advice/insights on this? Stapler didn't suffer from this issue.
from laravel-paperclip.
I don't understand why it should be different. I've been looking at the code, and the logic is the same as far as I can see:
Stapler and Paperclip share exactly this same logic:
Interpolator::filename()
calls directly onAttachment:originalFilename()
without any modification.originalFilename
is$this->instance->getAttribute("{$this->name}_file_name")
.
And both use :filename
in the default setup (for S3 in the case of Stapler, anyway).
So the most help I need is with understanding this.
If a short-term workaround is needed, I'd prefer adding something like a :url_decoded_filename
placeholder to the interpolator for this purpose.
from laravel-paperclip.
So it seems to be happening with characters that are otherwise valid in a URI. Particularly +
, ?
and #
.
Other characters (such as a space) seem to be automatically encoded by modern browsers to things like %20
-- but since characters such as #
could be part of a URL, they aren't encoded automatically. Seems like paperclip or czim/file-handling
should account for some of these characters in the filename when generating the URL. Happy to submit a PR, but not sure yet where to make this change 🤔
from laravel-paperclip.
Fascinating, I've logged out all the way back to symfony/http-foundation and I'm seeing that it's not encoding the filename.
laravel/framework @ v5.5.45
codesleeve/laravel-stapler @ v1.0.09
codesleeve/stapler @ v1.2.0
symfony/http-foundation @ v3.4.26
vendor/symfony/http-foundation/File/UploadedFile.php
public function getClientOriginalName()
{
\Log::info('getClientOriginalName', [$this->originalName]); // My log
return $this->originalName;
}
from laravel-paperclip.
Perhaps it's something to do with the database the filename is stored to? This too should be 100% identical between Stapler and Paperclip, but it might be worth examining.
from laravel-paperclip.
I'm loosing my mind over this issue. The problem has apparently disappeared (even though I tested multiple times). Closing issue.
from laravel-paperclip.
Alright, those are the fun ones! Let me know if it comes back to stay. 👍
from laravel-paperclip.
What what settings do you use for S3 storage? I've been seeing some issues with S3 in some cases..
from laravel-paperclip.
Update: I've been experimenting with Minio, trying to get a setup that simulates S3 well enough for automated testing. Unfortunately it does not appear that the behavior is identical. If anyone gets this working (or rather: gets it to break in the same way), I'd be obliged to hear the details!
from laravel-paperclip.
We just noticed this with filenames containing #
too.
from laravel-paperclip.
Related Issues (20)
- Is there a way to timeout remote URL fetches? HOT 1
- Laravel 7 HOT 3
- File goes missing at times after upload HOT 2
- Laravel 7 getAttributes() memory / loop problem HOT 1
- Allowed memory size and large uploads HOT 3
- Feature: attachment-level storage visibility configuration HOT 1
- Saving new Image from url causes Exception HOT 3
- Attachment attributes instantiated even when excluded from select statement HOT 6
- Manually able to trigger rotation on images HOT 2
- Processed variant ignores Orientation EXIF HOT 2
- attaching via url with url encoded filenames is problematic HOT 2
- AutoOrientStep not working in heroku HOT 4
- Strategy for changing interpolation HOT 1
- Re-uploading of image attachment with variants - variants have incorrect extension
- Deprecation Warning When Using PHP 8.1 HOT 2
- Laravel 9 update? HOT 5
- refresh command and s3 storage: new variants not created HOT 2
- paperclip:refresh with vapor and "No space left on device" HOT 3
- Dimentions Issue resize
- Can't delete attachment permanently. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-paperclip.