mimeEntityGetSafeFilename

SYNOPSIS

varchar mimeEntityGetSafeFilename(mimeEntity entityOrReader)

Parameters:

  • entityOrReader - A mimeEntity or mimeReader object

Returns:

  • varchar filename for entity, safe for filesystem


DESCRIPTION
The mimeEntityGetSafeFilename function returns the filename for the entity. The filename is based on the original message filename (see mimeEntityGetMessageFilename, here), but never contains a directory component, is always unique within the overall message, is safe for the filesystem (e.g. no device names nor control characters), and is never empty (one will be created). It will be index$.ext$ for the start body part (e.g. of multipart/related messages).

Additionally, the returned filename will be referenced by inline images/objects in the returned value of mimeEntityGetBody (here), when the "reparented" flag is given. Thus, if the reparented bodies of all the entities in a message are written out to their mimeEntityGetSafeFilename filenames in the same directory, a web browser viewing the directory should correctly display the message and any inline images. See the example below.


EXAMPLE

<$dir = "/var/www/html/theMessageDir">
  <while (mimeReaderMoveToNextEntity($reader) = '1')>
    <local path body>
    <$ret = (mimeEntityGetSafeFilename($reader))>
    <strfmt "%s%/%s" $dir $ret><$path = $ret>
    <$body = (mimeEntityGetBody($reader, "reparented" ))>
    <write $path><fmt "%s" $body></write>
  </while>


SEE ALSO
mimeEntityGetMessageFilename


Copyright © Thunderstone Software     Last updated: Jul 17 2021
Copyright © 2021 Thunderstone Software LLC. All rights reserved.