コード例 #1
0
 def getContentFileType(self, request, url):
     contentDisposition = 'content-disposition'
     if contentDisposition in request.headers:
         d = request.headers[contentDisposition]
         fileName = re.findall("filename=(.+)", d)[0]
         return FileFolderService.getFileType(fileName)
     else:
         return FileFolderService.getFileType(url)
コード例 #2
0
def displayBackground_image(uuid,number):
    print("PictureHash: "+number)
    if uuid is None:
        abort(404)
    authorizade = ServerDbSevice.getBackgroundUploadAuthorization(uuid)
    if authorizade is None:
        abort(404)
    filePath = GreenscreenBackgroundService.getCustomFilePathWithName(authorizade["targetPath"],uuid)
    imageAsByte = FileFolderService.readImage(filePath)
    return send_file(io.BytesIO(imageAsByte),
                     as_attachment=True,
                     attachment_filename=FileFolderService.getFileName(filePath),
                     mimetype='image/'+FileFolderService.getFileType(filePath).replace("\.",""))
コード例 #3
0
    def getCustomFilePathWithName(customBackgroundFolder:str,uuid:str, fileName:str = None):
        FileFolderService.createFolderIfNotExist(customBackgroundFolder)
        newFileName = uuid

        existingFileNames = []
        for fileUrl in FileFolderService.getFolderContentFiles(customBackgroundFolder):
            existingFileName = FileFolderService.getFileName(fileUrl)
            if existingFileName.startswith( newFileName ):
                existingFileNames.append(fileUrl)

        if fileName is None:
            if len(existingFileNames)> 0:
                newFileNameWithIndex = newFileName+"_"+str(len(existingFileNames))
                for existingFileUrl in existingFileNames:
                    existingFileName = FileFolderService.getFileName(existingFileUrl)
                    if existingFileName.startswith(newFileNameWithIndex):
                        return existingFileUrl


            return None
        else:
            type = FileFolderService.getFileType(fileName)
            return os.path.join(customBackgroundFolder,newFileName+"_"+str(len(existingFileNames)+1)+type)