Can you upload files on a Comet/APE environment?
-
21-04-2021 - |
Question
In a simple chat example using an APE Server and JavaScript on the client side which is pushing/polling information, is it possible to allow one user to upload a file (for example an image) and make the other users see that uploaded image, all in real time?
Thanks.
La solution
Comet applications are generally used for text-based messaging. You could feasibly encode the image and send that data over the wire but the best practice would most likely be:
- User uploads the image to the application using normal web app file upload functionality
- Server receives the file, in addition to some instruction about telling other users about the file, and triggers and event information the other users that a new file is present. This event should also include the location of the file
- The other users receive the update, access the file location and then display the new file in the application
If 3. were a web app then you could dynamically create a new image an set the src
attribute on it e.g. <img src="path_to_new_image" />
.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow