rejetto forum

[SOLVED] Uploading a MD5 file is forbidden?...

LeoNeeson · 23 · 19805

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
I've enabled the fingerprints feature today, just for testing. It would be great if HFS only generates MD5 files only when a new file is uploaded, and not all the files I already have on my server (I will see how this work, when I have more time).

For me (at least for personal & private use), MD5 is more than enough. Anyway, I'm open to new checksum systems, like SHA512.

Have you look at  menu>fingerprints> Create fingerprint on addition under (uploaded size in KB) to create md5 for new files only

MD5 information is only visible when account and password are added  to url based on this model

account:password@http://localhost/folder/file.txt#MD5

it would be more appropriate to create a MD5 or SHA512 by using macros since diff template only at each loading when it is finished


« Last Edit: March 19, 2016, 03:28:00 PM by Mars »


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
Have you look at  menu>fingerprints> Create fingerprint on addition under (uploaded size in KB) to create md5 for new files only

MD5 information is only visible when account and password are added  to url based on this model

account:password@http://localhost/folder/file.txt#MD5

it would be more appropriate to create a MD5 or SHA512 by using macros since diff template only at each loading when it is finished
I don't get it working. I'm not getting the #MD5 part (marked in red) included in the URL, and neither the .md5 file (only "hfs.comments.txt" is generated, besides the uploaded file).

For example, I get this URL:
http://TestUser:TestPass@localhost/FileTest.pdf

I'm not getting this (with the #MD5 part):
http://TestUser:TestPass@localhost/FileTest.pdf#12345678901234567890123456789012

I've enabled all the needed options. Have a look...


I never tried this option before. May be I need to configure something else... :-[
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
if your example FileTest.pdf is at root of VFS

go to disk and add a file new named FileTest.pdf.md5,

edit it as text and put only this next tex, and save

-LES_LAPINS_AIMENT_LES_CAROTTES-

save the file and browse the root folder -->move your  mouse on FileTest.pdf and you will see on statusbar thomething as

http://localhost/FileTest.pdf#!md5!-LES_LAPINS_AIMENT_LES_CAROTTES-

 ;D ;D

Without using hfs options, you can easily create the md5 only for new uploaded files with size >0

Quote
[upload-success]
{.inc|ok.}
{.comment|Reset md5 var.}
{.set|md5.}

<li> <a href="%item-url%">%item-name%</a>
<br />%item-size% @ %smart-speed%B/s
{.if|{.>|%item-size%|0.}|{:
   {.comment|Calculate md5.}
   {.set|md5|{.md5 file|%item-resource%.}.}
   {.comment|Create a new md5 file.}
   {.save|%item-resource%.md5|{.^md5.}.}
   {.comment|View md5 on Upload Result.}
   <br />MD5 : {.^md5.}
:}.}

{.if| {.length|%user%.} |{:
{.comment|.append|%folder-resource%\hfs.comments.txt |{.filename|%item-resource%.}=uploaded by %user%
/append.}
{.set item|%item-url%|comment=uploaded by %user%.}
 :}/if.}

 by replacing previously {.md5 file|%item-resource%.}  with an exec macro , it's possible to generate another type of Hash

Create md5, after each download is finished, might take a long time, the ideal would be to calculate during the transfer phase as and when the data arrives
 in both cases the total transfer time would increased but what would be the fastest, it remains to be seen.
« Last Edit: March 20, 2016, 02:22:18 PM by Mars »


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
if your example FileTest.pdf is at root of VFS

go to disk and add a file new named FileTest.pdf.md5,

edit it as text and put only this next tex, and save

-LES_LAPINS_AIMENT_LES_CAROTTES-

save the file and browse the root folder -->move your  mouse on FileTest.pdf and you will see on statusbar thomething as

http://localhost/FileTest.pdf#!md5!-LES_LAPINS_AIMENT_LES_CAROTTES-

 ;D ;D
LOL :P

Yes, it shows the MD5 in the URL (FileTest.pdf#!md5!-xxxxxxxxxxxxxxxxxxx) if I manually copy "FileTest.pdf" and "FileTest.pdf.md5" into a shared folder. But if I upload the file "FileTest.pdf" alone, the "FileTest.pdf.md5" file is still not being generated by HFS.

I will try this on a few days...
« Last Edit: April 01, 2016, 07:10:16 AM by LeoNeeson »
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
@Mars: Finally, I've got the time to test your change in the template code.

I've changed the code a little bit (marked in red) to generate a "normal" MD5 file (compatible with any external MD5 reader, like HashCheck v2.1.11)

Here is...
Quote
[upload-success]
{.inc|ok.}
{.comment|Reset md5 var.}
{.set|md5.}
<li> <a href="%item-url%">%item-name%</a>
<br />%item-size% @ %smart-speed%B/s
{.if|{.>|%item-size%|0.}|{:
   {.comment|Calculate md5.}
   {.set|md5|{.md5 file|%item-resource%.}.}
   {.comment|Create a new md5 file.}
   {.save|%item-resource%.md5|{.^md5.} *%item-name%.}
   {.comment|View md5 on Upload Result.}
   <br />MD5 : {.^md5.}
:}.}
{.if| {.length|%user%.} |{: {.comment|.append|%folder-resource%\hfs.comments.txt |{.filename|%item-resource%.}=uploaded by %user%
/append.}
{.set item|%item-url%|comment=uploaded by %user%.}
:}/if.}

Everything seems to work fine, but I have a problem in the generated MD5 file. Imagine I have a file called: "Rock & Roll.zip" (or any file containing the "&" character). Using the code above (with the change marked in red), that generates an invalid MD5 file (I mean, a md5 file which can't be read by an external MD5 reader, like HashCheck v2.1.11). The problem is the "&" character in the filename. I've tried several options:

Quote
   {.save|%item-resource%.md5|{.^md5.} *%item-name%.}
That generates the following MD5 File (it contains "&amp;" which makes the problem):
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF *Rock &amp; Roll.zip

Quote
   {.save|%item-resource%.md5|{.^md5.} *%item-resource%.}
That generates the following MD5 File (the file name now is OK, but an MD5 must not have the full path):
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF *C:\SharedFolder\Music\Rock & Roll.zip

Quote
   {.save|%item-resource%.md5|{.^md5.} *%filename%.extension.}
That generates the following MD5 File (non valid file name):
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF *%filename%.extension

In my example, a correct MD5 file should look like this:
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF *Rock & Roll.zip

What I need to change to make it work?...
« Last Edit: April 01, 2016, 07:45:07 AM by LeoNeeson »
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Quote
       {.save|%item-resource%.md5|{.^md5.} *%item-name%.}

That generates the following MD5 File (it contains "&amp;" which makes the problem):
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF *Rock &amp; Roll.zip

it is strange that the "&" character is replaced with its equivalent web, but if there is only him, it is simple to use macro "replace"

{.save|%item-resource%.md5|{.^md5.} {.replace |&amp;|&|*%item-name%.} /save.}


do not hesitate to use HFS  log  to evaluate expressions that are trying to use as "%filename%.extension", either using the macro {.add to log | ....}, either enabling debug macros to html


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
@Mars: Thank you. :) Thanks to your "replace" macro trick, I've removed the "full path" and used %item-resource% instead of %item-name%. Now works beautifully with any file I throw in (even works with another unicode symbols I've tested). This is the final result (with some cosmetic changes marked in green):

Quote
[upload-success]
{.inc|ok.}
{.comment|Reset md5 var.}
{.set|md5.}
<li> <a href="%item-url%">%item-name%</a>
<br /><b>Size & Speed:</b> %item-size% @ %smart-speed%B/s
{.if|{.>|%item-size%|0.}|{:
   {.comment|Calculate md5.}
   {.set|md5|{.md5 file|%item-resource%.}.}
   {.comment|Create a new md5 file.}
   {.save|%item-resource%.md5|{.^md5.} {.replace |%folder-resource%\|*|%item-resource%.} /save.}
   {.comment|View md5 on Upload Result.}
   <br /><b>MD5 Checksum:</b> {.^md5.}
:}.}
{.if| {.length|%user%.} |{: {.comment|.append|%folder-resource%\hfs.comments.txt |{.filename|%item-resource%.}=uploaded by %user%
/append.}
{.set item|%item-url%|comment=uploaded by %user%.}
:}/if.}
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline Fysack

  • Tireless poster
  • ****
    • Posts: 598
  • present picture
    • View Profile
    • Admin
Svitch svitch bitsh, battle against gods  8) woff woff woff
GOD CAN READ YOUR MIND