Hi guys,
I've been using this: (GRCodec forEncoding: 'utf-8') encode: aFilaname just before writing an uploaded file (that probably has diacritics in its name). The thing is that xsendfile doesn't find the ones with diacritics and the download fails. Non diacritical downloads works just fine. As workaround I'm forcing filenames to be non-diacritical while we find a solution. Wonder if any of you guys have solved making your webapp to offer files download even when the filenames has diacriticals? I mean with xsendfile (from a seaside app of course). sebastian_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
El mar, 28-09-2010 a las 13:03 -0300, Sebastian Sastre escribió:
> Hi guys, > > I've been using this: > > (GRCodec forEncoding: 'utf-8') encode: aFilaname > > just before writing an uploaded file (that probably has diacritics in its name). > > The thing is that xsendfile doesn't find the ones with diacritics and the download fails. Non diacritical downloads works just fine. > > As workaround I'm forcing filenames to be non-diacritical while we find a solution. > > Wonder if any of you guys have solved making your webapp to offer files download even when the filenames has diacriticals? I mean with xsendfile (from a seaside app of course). Store the files with numbers and save the original name in the database. Xsendfile the numbered file and state that the file should be offered with the original name. For example, in PHP: header("X-Sendfile: $numberedfile"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; file=\"$originalname\""); The downloaded file needs not to be the same name that the save as offered by the browser. Cheers > > sebastian_______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside -- Miguel Cobá http://miguel.leugim.com.mx _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Yeah, we actually saw that possibility but I was hoping to make the app not to be forced to maintain the original name in the database (so it can't never be confused about it nor inject maintenance costs).
What do you guys think about some other way to encode the filename that preserves the original (with diacritics) but for the OS (and xsendfile) it can look like a non-diacritical one? any ideas? (or encoders to suggest?) sebastian On Sep 28, 2010, at 1:11 PM, Miguel Cobá wrote: > El mar, 28-09-2010 a las 13:03 -0300, Sebastian Sastre escribió: >> Hi guys, >> >> I've been using this: >> >> (GRCodec forEncoding: 'utf-8') encode: aFilaname >> >> just before writing an uploaded file (that probably has diacritics in its name). >> >> The thing is that xsendfile doesn't find the ones with diacritics and the download fails. Non diacritical downloads works just fine. >> >> As workaround I'm forcing filenames to be non-diacritical while we find a solution. >> >> Wonder if any of you guys have solved making your webapp to offer files download even when the filenames has diacriticals? I mean with xsendfile (from a seaside app of course). > > Store the files with numbers and save the original name in the database. > Xsendfile the numbered file and state that the file should be offered > with the original name. For example, in PHP: > > header("X-Sendfile: $numberedfile"); > header("Content-Type: application/octet-stream"); > header("Content-Disposition: attachment; file=\"$originalname\""); > > The downloaded file needs not to be the same name that the save as > offered by the browser. > > Cheers > >> >> sebastian_______________________________________________ >> seaside mailing list >> [hidden email] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > -- > Miguel Cobá > http://miguel.leugim.com.mx > > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by sebastianconcept@gmail.co
Have you tried hexing the bytes and using that as a filename? _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Yeah, that is sexy.
It also needs it's complement: String class>>fromHex: anHexString "It returns the string that has its characters encoded in hex. 'el ñandú' asHex String fromHex: '656C20F1616E64FA'. Play with those." ^ String streamContents: [:stream| |source| source := anHexString readStream. [source atEnd] whileFalse: [ stream nextPut: (Character value: (Integer readFrom: (source next: 2) radix: 16))]]. sebastian On Sep 28, 2010, at 1:50 PM, Boris Popov, DeepCove Labs wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by sebastianconcept@gmail.co
To ensure you preserve characters, you need to go via the proper utf8 encoder when going from characters to bytes and vice versa.
-Boris (via BlackBerry) From: [hidden email] <[hidden email]> To: Seaside - general discussion <[hidden email]> Sent: Tue Sep 28 10:16:26 2010 Subject: Re: [Seaside] Downloads and filenames with diacritics It also needs it's complement: String class>>fromHex: anHexString "It returns the string that has its characters encoded in hex. 'el ñandú' asHex String fromHex: '656C20F1616E64FA'. Play with those." ^ String streamContents: [:stream| |source| source := anHexString readStream. [source atEnd] whileFalse: [ stream nextPut: (Character value: (Integer readFrom: (source next: 2) radix: 16))]]. sebastian On Sep 28, 2010, at 1:50 PM, Boris Popov, DeepCove Labs wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
yes, it's a double encoding/decoding process (that you can't do, in Pharo, unless you use the method I've wrote there)
On Sep 28, 2010, at 2:17 PM, Boris Popov, DeepCove Labs wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by sebastianconcept@gmail.co
2010/9/28 Sebastian Sastre <[hidden email]>:
> Hi guys, > > I've been using this: > > (GRCodec forEncoding: 'utf-8') encode: aFilaname > > just before writing an uploaded file (that probably has diacritics in its name). > > The thing is that xsendfile doesn't find the ones with diacritics and the download fails. Non diacritical downloads works just fine. > > As workaround I'm forcing filenames to be non-diacritical while we find a solution. > > Wonder if any of you guys have solved making your webapp to offer files download even when the filenames has diacriticals? I mean with xsendfile (from a seaside app of course). Uhm, I'd assume xsendfile uses the OS file system name encoding. Is that UTF-8 in your case? Cheers Philippe _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by sebastianconcept@gmail.co
2010/9/28 Sebastian Sastre <[hidden email]>:
> Yeah, we actually saw that possibility but I was hoping to make the app not to be forced to maintain the original name in the database (so it can't never be confused about it nor inject maintenance costs). > > What do you guys think about some other way to encode the filename that preserves the original (with diacritics) but for the OS (and xsendfile) it can look like a non-diacritical one? > > any ideas? (or encoders to suggest?) BASE64? Cheers Philippe _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by sebastianconcept@gmail.co
>>>>> "Sebastian" == Sebastian Sastre <[hidden email]> writes:
Sebastian> String class>>fromHex: anHexString Minor nit... that'd be "aHexString". H isn't a vowel, and even if you use the odd-sounding-to-me "an historic occasion", "H" is voiced here, not unvoiced like in "historic". -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[hidden email]> <URL:http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Philippe Marschall
It's linux ext3 but whatever it was using it wasn't playing nice with xsendfile, so
On Sep 28, 2010, at 4:17 PM, Philippe Marschall wrote: > 2010/9/28 Sebastian Sastre <[hidden email]>: >> Hi guys, >> >> I've been using this: >> >> (GRCodec forEncoding: 'utf-8') encode: aFilaname >> >> just before writing an uploaded file (that probably has diacritics in its name). >> >> The thing is that xsendfile doesn't find the ones with diacritics and the download fails. Non diacritical downloads works just fine. >> >> As workaround I'm forcing filenames to be non-diacritical while we find a solution. >> >> Wonder if any of you guys have solved making your webapp to offer files download even when the filenames has diacriticals? I mean with xsendfile (from a seaside app of course). > > Uhm, I'd assume xsendfile uses the OS file system name encoding. Is > that UTF-8 in your case? > > Cheers > Philippe > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
2010/9/29 Sebastian Sastre <[hidden email]>:
> It's linux ext3 but whatever it was using it wasn't playing nice with xsendfile, so Can you give us the output of `locale`? Thinking about it again, only ASCII is allowed in HTTP headers. Maybe you can try to percent encode the values. Cheers Philippe _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In a quick test, you'll find that it makes the filename to be longer (than using the hex encoding).
We'll stick to the hex idea to allow larger filename sizes (max 127 for the app user = 254 in the server's OS) and also because it's already in production since yesterday working just fine , so... But, sure, http encoding it's another option that should be perfectly fine. About locale... I didn't get you, but tell me what message to which object would give the answer to what you wanted to see and I can check it for you On Sep 29, 2010, at 3:52 PM, Philippe Marschall wrote: > 2010/9/29 Sebastian Sastre <[hidden email]>: >> It's linux ext3 but whatever it was using it wasn't playing nice with xsendfile, so > > Can you give us the output of `locale`? > > Thinking about it again, only ASCII is allowed in HTTP headers. Maybe > you can try to percent encode the values. > > Cheers > Philippe > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
2010/9/29 Sebastian Sastre <[hidden email]>:
> In a quick test, you'll find that it makes the filename to be longer (than using the hex encoding). > We'll stick to the hex idea to allow larger filename sizes (max 127 for the app user = 254 in the server's OS) and also because it's already in production since yesterday working just fine , so... > > But, sure, http encoding it's another option that should be perfectly fine. > > About locale... I didn't get you, but tell me what message to which object would give the answer to what you wanted to see and I can check it for you I meant typing locale in the console and pasting the output. Cheers Philippe _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
all is POSIX
On Sep 29, 2010, at 4:37 PM, Philippe Marschall wrote: > 2010/9/29 Sebastian Sastre <[hidden email]>: >> In a quick test, you'll find that it makes the filename to be longer (than using the hex encoding). >> We'll stick to the hex idea to allow larger filename sizes (max 127 for the app user = 254 in the server's OS) and also because it's already in production since yesterday working just fine , so... >> >> But, sure, http encoding it's another option that should be perfectly fine. >> >> About locale... I didn't get you, but tell me what message to which object would give the answer to what you wanted to see and I can check it for you > > I meant typing locale in the console and pasting the output. > > Cheers > Philippe > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |