Skip to content

Commit

Permalink
Merge pull request #1174 from SeasideSt/1043-Error-Improper-store-int…
Browse files Browse the repository at this point in the history
…o-indexable-object

Allow to select text encoding in web tool to upload files to a WAFileLibrary
  • Loading branch information
jbrichau authored Mar 14, 2020
2 parents 303f227 + 036ce00 commit 1f60381
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ addFile: aFile
aFile isNil ifTrue: [
"in case no file was selected for uploading"
^ self ].
contents := (aFile contentType isNil or: [ aFile contentType isBinary ])
contents := (aFile contentType isNil or: [ aFile contentType isBinary or: [ aFile contentType charSet isNil ] ])
ifTrue: [ aFile rawContents ]
ifFalse: [
GRPlatform current convertToSmalltalkNewlines: (aFile contentType charSet isNil
ifTrue: [ aFile rawContents ]
ifFalse: [ aFile contentsDecoded ]) ].
ifFalse: [ GRPlatform current convertToSmalltalkNewlines: aFile contentsDecoded ].
self class
addFileNamed: aFile fileName
contents: contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
actions
addFile: aFile withEncoding: aCodec
aFile isNil ifTrue: [
"in case no file was selected for uploading"
^ self ].

(aFile contentType isNil or: [ aFile contentType isBinary ])
ifFalse: [
(aCodec class == GRNullCodec)
ifFalse: [ aFile contentType charset: aCodec name ] ].

self library addFile: aFile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
rendering
renderAddFileOn: html
| theFile theCodec allCodecs |
allCodecs := GRCodec allCodecs.
html form multipart; with: [
html div: [
html text: 'Add file: '.
html break.
html fileUpload size: 40; on: #addFile of: self library.
html fileUpload
size: 40;
callback:[ :file | theFile := file ].
html space.
html submitButton: 'Add' ] ]
html text: 'with encoding: '.
html select
list: (allCodecs sorted: [ :a :b | a name <= b name ]);
labels: [ :codec | codec name ];
selected: (allCodecs detect: [ :codec | codec name = 'utf-8'] ifNone:[ nil ]);
callback:[:codec | theCodec := codec ].
html break.
html submitButton
value: 'Add';
callback: [ self addFile: theFile withEncoding: theCodec ] ] ]

This file was deleted.

0 comments on commit 1f60381

Please sign in to comment.