A weird case where image->save changes the image file name provided

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

A weird case where image->save changes the image file name provided

bienvenue
Hi list

Lasso 8.6 / CentOS 6.5

we have a form to upload and display an image on screen.
Iterating File_Uploads, checking errors, the code processes the upload file and first sets the name as follow :

local: 'name' = #catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find: 'OrigExtension');

Where #temp is an iteration within File_Uploads

That is intended to define the real file name as "234_234567.jpg" for instance.

Then we process the file for scaling in 3 different ratio/size
Each time we use ->save to… save the file in the right directory and it's name in database.
As in :
#medium->save( #folder_M #name ) ;
or
#small->save( #folder_S #name ) ;

The file path should be as /Path/folderNameForSmall/234_234567.jpg

File is saved in the right folder but sometimes the name is changed in a very weird way.

The value of #name saved in DB is ok, checked with an output on screen…
output of #small->File shows sometimes a different name

From our tests, we noticed that the problem never happened with a #name content with letter as "my_image.jpg" for instance
Or with group of digit more or less than 6, it seems that sometimes when the name contains part with exactly 6 digits the name of the file is changed as ->save occurs…

For instance theese are OK :
Name   "my_image.jpg"  = File = "my_image.jpg"
Name   "my_1234567.jpg"  = File  "my_1234567.jpg"
Name   "7281923-6669803.png"  = File  "7281923-6669803.png"
Name   "7281923-666980.png"  = File  "7281923-666980.png"
Name   "1-289164.png"  = File  "1-289164.png"
Name   "728-289164.png"  = File  "728-289164.png"

But here file name is changed :
Name   "728192-666980.png"  ≠ File "728192-666980.gng" Here the extension has change !
Name   "12-666980.png"  ≠ File "12-666080.png" Here 9 becomes 0 !
Name   "12-632075.png"  ≠ File "12-632575.png" Here 0 becomes 5 !
Name   "11-132725.png"  ≠ File "11-132525.png" Here 7 becomes 5 !

In this cases the file real name is NOT as intended in the real folder ! so the image cannot be displayed on screen from recorded name in DB
the ->save has changed the content of the name ?!

Well. We will change our naming convention by adding a letter in the name, it seems to work…
But, if any of you has a hint about what happens in our case, we'll take it !

Regards
JPK
----
E SYSTEMES - Lille France


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: A weird case where image->save changes the image file name provided

stevepiercy
It's impossible to say what is wrong without seeing the full
code sample.

There are also potential issues.  What if the user uploads a
file without a file extension or which is not an image type?  
Use 'magic' to sniff the file type.
http://lasso.2283332.n4.nabble.com/File-upload-size-limit-tt3151383.html#a3151386

As an aside, preferred syntax in Lasso 8 for this:

local: 'name' =
#catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find: 'OrigExtension');

would be:

local('name') = #catalogue -> structure_id + '_' +
#catalogue->reference + '.' + #temp->Find('OrigExtension');

because:

* colon syntax is deprecated in Lasso 9
* parentheses syntax removes ambiguity of colon syntax
* + is explicit string concatenation, whereas omitting + is
implicit.  Explicit > Implicit.

--steve


On 11/5/14 at 10:10 PM, [hidden email] (bienvenue) pronounced:

>Hi list
>
>Lasso 8.6 / CentOS 6.5
>
>we have a form to upload and display an image on screen.
>Iterating File_Uploads, checking errors, the code processes the
>upload file and first sets the name as follow :
>
>local: 'name' =
>#catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find:
>'OrigExtension');
>
>Where #temp is an iteration within File_Uploads
>
>That is intended to define the real file name as "234_234567.jpg" for instance.
>
>Then we process the file for scaling in 3 different ratio/size
>Each time we use ->save to… save the file in the right
>directory and it's name in database.
>As in : #medium->save( #folder_M #name ) ;
>or
>#small->save( #folder_S #name ) ;
>
>The file path should be as /Path/folderNameForSmall/234_234567.jpg
>
>File is saved in the right folder but sometimes the name is changed in a very weird way.
>
>The value of #name saved in DB is ok, checked with an output on screen…
>output of #small->File shows sometimes a different name
>
> From our tests, we noticed that the problem never happened
>with a #name content with letter as "my_image.jpg" for instance
>Or with group of digit more or less than 6, it seems that
>sometimes when the name contains part with exactly 6 digits the
>name of the file is changed as ->save occurs…
>
>For instance theese are OK :
>Name   "my_image.jpg"  = File = "my_image.jpg"
>Name   "my_1234567.jpg"  = File  "my_1234567.jpg"
>Name   "7281923-6669803.png"  = File  "7281923-6669803.png"
>Name   "7281923-666980.png"  = File  "7281923-666980.png"
>Name   "1-289164.png"  = File  "1-289164.png"
>Name   "728-289164.png"  = File  "728-289164.png"
>
>But here file name is changed : Name   "728192-666980.png"  ≠
>File "728192-666980.gng" Here the extension has change !
>Name   "12-666980.png"  ≠ File "12-666080.png" Here 9 becomes 0 !
>Name   "12-632075.png"  ≠ File "12-632575.png" Here 0 becomes 5 !
>Name   "11-132725.png"  ≠ File "11-132525.png" Here 7 becomes 5 !
>
>In this cases the file real name is NOT as intended in the real
>folder ! so the image cannot be displayed on screen from
>recorded name in DB
>the ->save has changed the content of the name ?!
>
>Well. We will change our naming convention by adding a letter
>in the name, it seems to work…
>But, if any of you has a hint about what happens in our case, we'll take it !
>
>Regards
>JPK
>----
>E SYSTEMES - Lille France
>
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.StevePiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: A weird case where image->save changes the image file name provided

bienvenue
Thanks for your good pieces of advice and hints for good pratices Steeve.
Although we have yet no explaination for this strange like-hexa-image-save-name changing…

Regards
JPK
---
E SYSTEMES - Lille France

Le 5 nov. 2014 à 22:27, Steve Piercy - Website Builder <[hidden email]> a écrit :

> It's impossible to say what is wrong without seeing the full code sample.
>
> There are also potential issues.  What if the user uploads a file without a file extension or which is not an image type?  Use 'magic' to sniff the file type.
> http://lasso.2283332.n4.nabble.com/File-upload-size-limit-tt3151383.html#a3151386
>
> As an aside, preferred syntax in Lasso 8 for this:
>
> local: 'name' = #catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find: 'OrigExtension');
>
> would be:
>
> local('name') = #catalogue -> structure_id + '_' + #catalogue->reference + '.' + #temp->Find('OrigExtension');
>
> because:
>
> * colon syntax is deprecated in Lasso 9
> * parentheses syntax removes ambiguity of colon syntax
> * + is explicit string concatenation, whereas omitting + is implicit.  Explicit > Implicit.
>
> --steve
>
>
> On 11/5/14 at 10:10 PM, [hidden email] (bienvenue) pronounced:
>
>> Hi list
>>
>> Lasso 8.6 / CentOS 6.5
>>
>> we have a form to upload and display an image on screen.
>> Iterating File_Uploads, checking errors, the code processes the upload file and first sets the name as follow :
>>
>> local: 'name' = #catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find: 'OrigExtension');
>>
>> ( … )
>>
>> For instance theese are OK :
>> Name   "my_image.jpg"  = File = "my_image.jpg"
>> Name   "my_1234567.jpg"  = File  "my_1234567.jpg"
>> Name   "7281923-6669803.png"  = File  "7281923-6669803.png"
>> Name   "7281923-666980.png"  = File  "7281923-666980.png"
>> Name   "1-289164.png"  = File  "1-289164.png"
>> Name   "728-289164.png"  = File  "728-289164.png"
>>
>> But here file name is changed : Name   "728192-666980.png"  ≠ File "728192-666980.gng" Here the extension has change !
>> Name   "12-666980.png"  ≠ File "12-666080.png" Here 9 becomes 0 !
>> Name   "12-632075.png"  ≠ File "12-632575.png" Here 0 becomes 5 !
>> Name   "11-132725.png"  ≠ File "11-132525.png" Here 7 becomes 5 !
>>
>> In this cases the file real name is NOT as intended in the real folder ! so the image cannot be displayed on screen from recorded name in DB
>> the ->save has changed the content of the name ?!
>>
>> Well. We will change our naming convention by adding a letter in the name, it seems to work…
>> But, if any of you has a hint about what happens in our case, we'll take it !
>>
>> Regards
>> JPK
>> ----
>> E SYSTEMES - Lille France
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy              Website Builder              Soquel, CA
> <[hidden email]>               <http://www.StevePiercy.com/>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: A weird case where image->save changes the image file name provided

stevepiercy
 From reading the tea leaves, my guess would be that you are
creating an iterator from file_listdirectory, which does not
sort as you might expect on CentOS, thus the names do not correlate.

Again, however, no code sample, impossible to say for sure.  If
you paste your code, removing any possible security information,
then it may be possible to help.

--steve


On 11/6/14 at 9:38 AM, [hidden email] (bienvenue) pronounced:

>Thanks for your good pieces of advice and hints for good pratices Steeve.
>Although we have yet no explaination for this strange like-hexa-image-save-name changing…
>
>Regards
>JPK
>---
>E SYSTEMES - Lille France
>
>Le 5 nov. 2014 à 22:27, Steve Piercy - Website Builder <[hidden email]> a écrit :
>
>>It's impossible to say what is wrong without seeing the full code sample.
>>
>>There are also potential issues.  What if the user uploads a file without a file
>extension or which is not an image type?  Use 'magic' to sniff the file type.
>>http://lasso.2283332.n4.nabble.com/File-upload-size-limit-tt3151383.html#a3151386
>>
>>As an aside, preferred syntax in Lasso 8 for this:
>>
>>local: 'name' = #catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find:
>'OrigExtension');
>>
>>would be:
>>
>>local('name') = #catalogue -> structure_id + '_' + #catalogue->reference + '.' +
>#temp->Find('OrigExtension');
>>
>>because:
>>
>>* colon syntax is deprecated in Lasso 9
>>* parentheses syntax removes ambiguity of colon syntax
>>* + is explicit string concatenation, whereas omitting + is implicit.  Explicit >
>Implicit.
>>
>>--steve
>>
>>
>>On 11/5/14 at 10:10 PM, [hidden email] (bienvenue) pronounced:
>>
>>> Hi list
>>>   Lasso 8.6 / CentOS 6.5
>>>   we have a form to upload and display an image on screen.
>>> Iterating File_Uploads, checking errors, the code processes the upload file and first
>sets the name as follow :
>>>   local: 'name' = #catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find:
>'OrigExtension');
>>>   ( … )
>>>   For instance theese are OK :
>>> Name   "my_image.jpg"  = File = "my_image.jpg"
>>> Name   "my_1234567.jpg"  = File  "my_1234567.jpg"
>>> Name   "7281923-6669803.png"  = File  "7281923-6669803.png"
>>> Name   "7281923-666980.png"  = File  "7281923-666980.png"
>>> Name   "1-289164.png"  = File  "1-289164.png"
>>> Name   "728-289164.png"  = File  "728-289164.png"
>>>   But here file name is changed : Name  
>>>"728192-666980.png"  ≠ File "728192-666980.gng"
>Here the extension has change !
>>> Name   "12-666980.png"  ≠ File "12-666080.png" Here 9 becomes 0 !
>>> Name   "12-632075.png"  ≠ File "12-632575.png" Here 0 becomes 5 !
>>> Name   "11-132725.png"  ≠ File "11-132525.png" Here 7 becomes 5 !
>>>   In this cases the file real name is NOT as intended in the
>>>real folder ! so the image
>cannot be displayed on screen from recorded name in DB
>>> the ->save has changed the content of the name ?!
>>>   Well. We will change our naming convention by adding a
>>>letter in the name, it seems to
>work…
>>> But, if any of you has a hint about what happens in our case, we'll take it !
>>>   Regards
>>> JPK
>>> ----
>>> E SYSTEMES - Lille France
>>
>>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>Steve Piercy              Website Builder              Soquel, CA
>><[hidden email]>               <http://www.StevePiercy.com/>
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.StevePiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: A weird case where image->save changes the image file name provided

bienvenue
We have change our way to manage with that path issue...

In fact, we guess that it is about a known image tags bug with Lasso 8.6.2 on CentOS 6.5, as reported in that lassoTalk Post :

Aug 27, 2013; 6:18pm / Image Tags on 8.6.2
http://lasso.2283332.n4.nabble.com/Image-Tags-on-8-6-2-td4639281.html

The truth is elsewere...
In our app code we indeed use :

var: 'myImage' = image(#target);

Were local target is the path...

Something in the image magick lasso implementation modifies the name of the file when saved at...
$myImage->save;

So the saved path in the data base and the name of the file does not match and the view throws a 404 error when trying to fetch the ressource in the assets...

Wierd but fact.

Regards
JPK
---
E SYSTEMES - Lille France
-------------

Le 6 nov. 2014 à 09:50, Steve Piercy - Website Builder <[hidden email]> a écrit :

> From reading the tea leaves, my guess would be that you are creating an iterator from file_listdirectory, which does not sort as you might expect on CentOS, thus the names do not correlate.
>
> Again, however, no code sample, impossible to say for sure.  If you paste your code, removing any possible security information, then it may be possible to help.
>
> --steve
>
>
> On 11/6/14 at 9:38 AM, [hidden email] (bienvenue) pronounced:
>
>> Thanks for your good pieces of advice and hints for good pratices Steeve.
>> Although we have yet no explaination for this strange like-hexa-image-save-name changing…
>>
>> Regards
>> JPK
>> ---
>> E SYSTEMES - Lille France
>>
>> Le 5 nov. 2014 à 22:27, Steve Piercy - Website Builder <[hidden email]> a écrit :
>>
>>> It's impossible to say what is wrong without seeing the full code sample.
>>>
>>> There are also potential issues.  What if the user uploads a file without a file
>> extension or which is not an image type?  Use 'magic' to sniff the file type.
>>> http://lasso.2283332.n4.nabble.com/File-upload-size-limit-tt3151383.html#a3151386
>>>
>>> As an aside, preferred syntax in Lasso 8 for this:
>>>
>>> local: 'name' = #catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find:
>> 'OrigExtension');
>>>
>>> would be:
>>>
>>> local('name') = #catalogue -> structure_id + '_' + #catalogue->reference + '.' +
>> #temp->Find('OrigExtension');
>>>
>>> because:
>>>
>>> * colon syntax is deprecated in Lasso 9
>>> * parentheses syntax removes ambiguity of colon syntax
>>> * + is explicit string concatenation, whereas omitting + is implicit.  Explicit >
>> Implicit.
>>>
>>> --steve
>>>
>>>
>>> On 11/5/14 at 10:10 PM, [hidden email] (bienvenue) pronounced:
>>>
>>>> Hi list
>>>>  Lasso 8.6 / CentOS 6.5
>>>>  we have a form to upload and display an image on screen.
>>>> Iterating File_Uploads, checking errors, the code processes the upload file and first
>> sets the name as follow :
>>>>  local: 'name' = #catalogue->structure_id'_'#catalogue->reference'.'(#temp->Find:
>> 'OrigExtension');
>>>>  ( … )
>>>>  For instance theese are OK :
>>>> Name   "my_image.jpg"  = File = "my_image.jpg"
>>>> Name   "my_1234567.jpg"  = File  "my_1234567.jpg"
>>>> Name   "7281923-6669803.png"  = File  "7281923-6669803.png"
>>>> Name   "7281923-666980.png"  = File  "7281923-666980.png"
>>>> Name   "1-289164.png"  = File  "1-289164.png"
>>>> Name   "728-289164.png"  = File  "728-289164.png"
>>>>  But here file name is changed : Name   "728192-666980.png"  ≠ File "728192-666980.gng"
>> Here the extension has change !
>>>> Name   "12-666980.png"  ≠ File "12-666080.png" Here 9 becomes 0 !
>>>> Name   "12-632075.png"  ≠ File "12-632575.png" Here 0 becomes 5 !
>>>> Name   "11-132725.png"  ≠ File "11-132525.png" Here 7 becomes 5 !
>>>>  In this cases the file real name is NOT as intended in the real folder ! so the image
>> cannot be displayed on screen from recorded name in DB
>>>> the ->save has changed the content of the name ?!
>>>>  Well. We will change our naming convention by adding a letter in the name, it seems to
>> work…
>>>> But, if any of you has a hint about what happens in our case, we'll take it !
>>>>  Regards
>>>> JPK
>>>> ----
>>>> E SYSTEMES - Lille France
>>>
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>> Steve Piercy              Website Builder              Soquel, CA
>>> <[hidden email]>               <http://www.StevePiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>