Manuscript (Case [Issue]22603) Streams - Binary file fails for ZnMimePart class>>#fieldName:fileNamed:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Manuscript (Case [Issue]22603) Streams - Binary file fails for ZnMimePart class>>#fieldName:fileNamed:

Pharo Issue Tracker
Manuscript Notification
avatar
Wouter van Zuilen opened Case 22603: Binary file fails for ZnMimePart class>>#fieldName:fileNamed: and assigned it to Everyone:
Bug in Project:  Streams: 1. Pharo Image  •  You are subscribed to this case
In the latest Pharo 7 64 bit build running on MacOS the following fails:

<code>ZnMimePart fieldName: 'file' fileNamed: '/path/to/aPdfFile.pdf'</code>

In this method an instance of a ZnCharacterReadStream receives the message #binary which it not understands.

I would suggest the following fix:

<code>fieldName: fieldName fileNamed: fileName
| mimeType size fileStream entity baseName |
mimeType := ZnMimeType forFilenameExtension: (ZnFileSystemUtils extensionFor: fileName).
fileStream := mimeType isBinary
ifTrue: [ fileName asFileReference binaryReadStream ]
ifFalse: [ fileName asFileReference readStream ].
size := ZnFileSystemUtils fileSizeFor: fileName.
(entity := ZnStreamingEntity type: mimeType length: size) stream: fileStream.
baseName := ZnFileSystemUtils baseNameFor: fileName.
^ self fieldName: fieldName fileName: baseName entity: entity</code>
Priority Priority: 5 – Fix If Time Status Status: Work Needed
Assigned To Assigned to: Everyone Milestone Milestone: Later

Go to Case
No longer need updates? Unsubscribe from this case.

Don't want Manuscript notifications anymore? Update your preferences.

Manuscript

_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
https://lists.gforge.inria.fr/mailman/listinfo/pharo-bugtracker