-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use allow and block lists for uploading files and images #3556
Changes from 3 commits
f767081
c585bce
75d700c
a22a247
7101167
783cf05
5df9fb9
b615255
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,26 +405,41 @@ open class ComposerVC: _ViewController, | |
|
||
/// The view controller for selecting image attachments. | ||
open private(set) lazy var mediaPickerVC: UIViewController = { | ||
let mediaTypes: [String] = { | ||
let availableTypes = UIImagePickerController.availableMediaTypes(for: .savedPhotosAlbum) ?? ["public.image"] | ||
let allowed = channelController?.client.appSettings?.imageUploadConfig.allowedUTITypes ?? [] | ||
return allowed.isEmpty ? availableTypes : allowed | ||
}() | ||
let picker = UIImagePickerController() | ||
picker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .savedPhotosAlbum) ?? ["public.image"] | ||
picker.mediaTypes = mediaTypes | ||
picker.sourceType = .savedPhotosAlbum | ||
picker.delegate = self | ||
return picker | ||
}() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default we get
Currently I did not figure out how to handle the case where I would create So for now, I am only setting allow list to the picker. Which means that, I could still select a jpeg file and start the upload. Upload fails immediately because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I spent some more time and does not seem feasible. I'll keep it like that and if we end up finding a way, we can change it later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am taking this out because it is a risky change. Did not realise this before. Picker will throw an exception if I would just do |
||
|
||
/// The View Controller for taking a picture. | ||
open private(set) lazy var cameraVC: UIViewController = { | ||
let mediaTypes: [String] = { | ||
let availableTypes = UIImagePickerController.availableMediaTypes(for: .camera) ?? ["public.image"] | ||
let allowed = channelController?.client.appSettings?.imageUploadConfig.allowedUTITypes ?? [] | ||
return allowed.isEmpty ? availableTypes : allowed | ||
}() | ||
let camera = UIImagePickerController() | ||
camera.sourceType = .camera | ||
camera.modalPresentationStyle = .overFullScreen | ||
camera.mediaTypes = UIImagePickerController.availableMediaTypes(for: .camera) ?? ["public.image"] | ||
camera.mediaTypes = mediaTypes | ||
camera.delegate = self | ||
return camera | ||
}() | ||
|
||
/// The view controller for selecting file attachments. | ||
open private(set) lazy var filePickerVC: UIViewController = { | ||
let picker = UIDocumentPickerViewController(documentTypes: ["public.item"], in: .import) | ||
let documentTypes: [String] = { | ||
let availableTypes = ["public.item"] | ||
let allowed = channelController?.client.appSettings?.fileUploadConfig.allowedUTITypes ?? [] | ||
return allowed.isEmpty ? availableTypes : allowed | ||
}() | ||
let picker = UIDocumentPickerViewController(documentTypes: documentTypes, in: .import) | ||
picker.delegate = self | ||
picker.allowsMultipleSelection = true | ||
return picker | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to add an entry to StreamChatUI, maybe a # Changed section that we now change the media types based on these configs @laevandus WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, it should be mentioned. Thanks