2022-04-01 22:22:33 +00:00
|
|
|
accessing
|
|
|
|
exportProfileImageOn: fileReference
|
|
|
|
|
2022-04-07 16:28:18 +00:00
|
|
|
| file tempFile tempFileHash fileHash |
|
2022-04-01 22:22:33 +00:00
|
|
|
file := fileReference asFileReference.
|
2022-04-07 16:28:18 +00:00
|
|
|
file exists
|
|
|
|
ifFalse: [ file ensureCreateFile.
|
|
|
|
file binaryWriteStreamDo: [ :stream |
|
|
|
|
stream nextPutAll: profileImageUrl retrieveContents ].
|
|
|
|
super class inform: 'Exported as: ', String cr, file fullName.
|
|
|
|
^ file]
|
|
|
|
|
|
|
|
ifTrue: [
|
|
|
|
tempFile := FileLocator temp / fileReference basename.
|
|
|
|
tempFile ensureCreateFile.
|
|
|
|
tempFile binaryWriteStreamDo: [ :stream |
|
2022-04-16 06:37:11 +00:00
|
|
|
stream nextPutAll: profileImageUrl asUrl retrieveContents.
|
2022-04-07 16:28:18 +00:00
|
|
|
super class
|
|
|
|
inform: 'Exported as: ', String cr, tempFile fullName. ].
|
|
|
|
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: 'openssl';
|
|
|
|
arguments: { 'dgst' . '-sha256' . file fullName};
|
|
|
|
workingDirectory: (self folder)fullName;
|
|
|
|
redirectStdout;
|
|
|
|
redirectStderr;
|
|
|
|
runAndWaitOnExitDo: [ :process :outString |
|
|
|
|
fileHash := (outString splitOn: ' ' ) second trimmed].
|
|
|
|
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: 'openssl';
|
|
|
|
arguments: { 'dgst' . '-sha256' . tempFile fullName};
|
|
|
|
workingDirectory: (self folder)fullName;
|
|
|
|
redirectStdout;
|
|
|
|
redirectStderr;
|
|
|
|
runAndWaitOnExitDo: [ :process :outString |
|
|
|
|
tempFileHash := (outString splitOn: ' ' ) second trimmed].
|
|
|
|
|
|
|
|
fileHash = tempFileHash
|
|
|
|
ifFalse: [
|
|
|
|
file copyTo: self folder /
|
|
|
|
(file basenameWithoutExtension , '-',
|
|
|
|
('-' join:
|
|
|
|
((file creationTime asLocalStringYMDHM) splitOn: ' ')), '.jpg').
|
|
|
|
file ensureDelete.
|
|
|
|
^ { 'Profile image changed' ->
|
|
|
|
(tempFile moveTo: file)} asDictionary ]].
|
|
|
|
^ { 'Same Profile Image' -> file } asDictionary
|