def get(self, request, *args, **kwargs): result = True try: file_id = kwargs.get('file_id') temp_file = FileInfoService.get_file(int(file_id), TempFileMongoFile) if temp_file: result = temp_file else: result = FileInfoService.get_file(int(file_id), IssueMongoFile) except Exception as ex: result = str(ex) SimpleLogger.exception(ex) return HttpResponse(result, content_type="application/octet-stream")
def download_document(file_id): if file_id.isnumeric(): document = ProjectDocument.objects.get(int(file_id)) temp_file = FileInfoService.get_file(int(document.FileID), ProjectDocumentMongoFile) else: temp_file = TempFileMongoFile.objects.get(file_id) return temp_file
def download_file(request, package_file_id): result = True try: file_info = FileInfo.objects.get(int(package_file_id)) result = FileInfoService.get_file(int(package_file_id), IssueMongoFile) except Exception as ex: result = str(ex) SimpleLogger.exception(ex) return HttpResponse(result, content_type="application/" + file_info.FileSuffixes)
def get_issue_attachment_viewer(self,issue_id,attachment_id): temp_file=FileInfoService.get_file(int(attachment_id),IssueMongoFile).read() kind = filetype.guess(temp_file) file_type=0 file_content="" if kind: if kind.mime.startswith("image"): file_type=1 if kind.mime.startswith("video"): file_type=2 pagefileds={'file_id':attachment_id,'file_type':file_type,'issue_id':issue_id} return self.get_webpart(pagefileds,ProjectIssuePath.issue_attachment_viewer)
def get(self, request, *args, **kwargs): result = True try: file_id = kwargs.get('file_id') file_info = FileInfo.objects.get(int(file_id)) result = FileInfoService.get_file(int(file_id), FortestingMongoFile) except Exception as ex: result = str(ex) SimpleLogger.exception(ex) return HttpResponse(result, content_type="application/" + file_info.FileSuffixes)
def download_attachment(file_id): return FileInfoService.get_file(file_id, FortestingMongoFile)
def download_attachment(file_id, mongo_model): return FileInfoService.get_file(int(file_id), mongo_model)
def download_attachment(file_id): return FileInfoService.get_file(int(file_id), IssueMongoFile)