Iframe funcs.
This commit is contained in:
		
							parent
							
								
									be35a6caf0
								
							
						
					
					
						commit
						2cfb8fe308
					
				| @ -12,6 +12,10 @@ class BaseView(web.View): | ||||
|             return web.HTTPFound("/") | ||||
|         return await super()._iter() | ||||
| 
 | ||||
|     @property  | ||||
|     def base_url(self): | ||||
|         return str(self.request.url.with_path('').with_query('')) | ||||
| 
 | ||||
|     @property | ||||
|     def app(self): | ||||
|         return self.request.app | ||||
|  | ||||
| @ -38,6 +38,17 @@ class UploadView(BaseView): | ||||
|         drive = await self.services.drive.get_or_create(user_uid=self.request.session.get("uid")) | ||||
| 
 | ||||
|         print(str(drive), flush=True) | ||||
|         extension_types = { | ||||
|             ".jpg": "image", | ||||
|             ".gif": "image", | ||||
|             ".png": "image", | ||||
|             ".jpeg": "image", | ||||
|             ".mp4": "video", | ||||
|             ".mp3": "audio", | ||||
|             ".pdf": "document", | ||||
|             ".doc": "document", | ||||
|             ".docx": "document" | ||||
|         } | ||||
| 
 | ||||
|         while field := await reader.next(): | ||||
|             if field.name == "channel_uid": | ||||
| @ -59,8 +70,18 @@ class UploadView(BaseView): | ||||
|                 drive["uid"], filename, str(file_path.absolute()), file_path.stat().st_size, file_path.suffix | ||||
|             ) | ||||
|             | ||||
|             type_ = "unknown" | ||||
|             extension = "." + filename.split(".")[-1] | ||||
|             if extension in extension_types: | ||||
|                 type_ = extension_types[extension]  | ||||
|              | ||||
|             await self.services.drive_item.save(drive_item) | ||||
|             response = "<iframe width=\"100%\" frameborder=\"0\" allowfullscreen title=\"Embedded\" src=\"" + self.base_url + "/drive.bin/" + drive_item["uid"] + "\"></iframe>\n" | ||||
|             if type_ == "image": | ||||
|                 response = "" | ||||
| 
 | ||||
|             await self.services.chat.send( | ||||
|                 self.request.session.get("uid"), channel_uid, f"" | ||||
|                 self.request.session.get("uid"), channel_uid, response | ||||
|             ) | ||||
|             print(drive_item, flush=True) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user