• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.check_upload函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.developers.utils.check_upload函数的典型用法代码示例。如果您正苦于以下问题:Python check_upload函数的具体用法?Python check_upload怎么用?Python check_upload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_upload函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: clean_file

    def clean_file(self):
        file_ = self.cleaned_data.get("file", {})
        file_obj = parse(file_)
        errors, hash_ = check_upload(file_obj, self.upload_type, file_["type"])
        if errors:
            raise forms.ValidationError(errors)

        self.hash_ = hash_
        return file_
开发者ID:gurumukhi,项目名称:zamboni,代码行数:9,代码来源:forms.py


示例2: clean_file

    def clean_file(self):
        file_ = self.cleaned_data.get('file', {})
        file_obj = parse(file_)
        errors, hash_ = check_upload(file_obj, 'preview', file_['type'])
        if errors:
            raise forms.ValidationError(errors)

        self.hash_ = hash_
        return file_
开发者ID:flyun,项目名称:zamboni,代码行数:9,代码来源:forms.py


示例3: test_promo_img_too_small

    def test_promo_img_too_small(self):
        with local_storage.open(get_image_path('preview.jpg')) as f:
            errors, upload_hash = check_upload(f, 'promo_img', 'image/png')
            ok_(errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'promo_img',
                                        upload_hash)
            ok_(os.path.isfile(tmp_img_path))
开发者ID:jamesthechamp,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py


示例4: test_promo_img_ok

    def test_promo_img_ok(self):
        with local_storage.open(get_image_path('game_1050.jpg')) as f:
            errors, upload_hash = check_upload(f, 'promo_img', 'image/png')
            ok_(not errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'promo_img',
                                        upload_hash)
            ok_(private_storage.exists(tmp_img_path))
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py


示例5: test_icon_ok

    def test_icon_ok(self):
        with local_storage.open(get_image_path('mozilla-sq.png')) as f:
            errors, upload_hash = check_upload(f, 'icon', 'image/png')
            ok_(not errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'icon',
                                        upload_hash)
            ok_(os.path.isfile(tmp_img_path))
开发者ID:jamesthechamp,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py


示例6: test_preview_too_small

    def test_preview_too_small(self):
        with local_storage.open(get_image_path('mkt_icon_72.png')) as f:
            errors, upload_hash = check_upload(f, 'preview', 'image/png')
            ok_(errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'preview',
                                        upload_hash)
            ok_(private_storage.exists(tmp_img_path))
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py


示例7: clean_promo_img

    def clean_promo_img(self):
        image = self.cleaned_data[self.upload_type]
        errors, upload_hash = check_upload(image, self.upload_type,
                                           image.content_type)
        if errors:
            log.info('Promo img errors: %s' % errors)
            raise forms.ValidationError(errors)

        self.upload_hash = upload_hash
        return image
开发者ID:shahbaz17,项目名称:zamboni,代码行数:10,代码来源:forms.py


示例8: clean_file

    def clean_file(self):
        file_ = self.cleaned_data.get('file', {})
        try:
            if not set(['data', 'type']).issubset(set(file_.keys())):
                raise forms.ValidationError('Type and data are required.')
        except AttributeError:
            raise forms.ValidationError('File must be a dictionary.')

        file_obj = StringIO.StringIO(base64.b64decode(file_['data']))
        errors, hash_ = check_upload(file_obj, 'graphic', file_['type'])
        if errors:
            raise forms.ValidationError(errors)

        self.hash_ = hash_
        return file_
开发者ID:Sancus,项目名称:zamboni,代码行数:15,代码来源:forms.py


示例9: ajax_upload_media

def ajax_upload_media(request, upload_type):
    errors = []
    upload_hash = ""

    if "upload_image" in request.FILES:
        upload_preview = request.FILES["upload_image"]
        upload_preview.seek(0)
        content_type = upload_preview.content_type
        errors, upload_hash = check_upload(upload_preview, upload_type, content_type)

    else:
        errors.append(_("There was an error uploading your preview."))

    if errors:
        upload_hash = ""

    return {"upload_hash": upload_hash, "errors": errors}
开发者ID:ngokevin,项目名称:zamboni,代码行数:17,代码来源:views.py


示例10: ajax_upload_media

def ajax_upload_media(request, upload_type):
    errors = []
    upload_hash = ''

    if 'upload_image' in request.FILES:
        upload_preview = request.FILES['upload_image']
        upload_preview.seek(0)
        content_type = upload_preview.content_type
        errors, upload_hash = check_upload(upload_preview, upload_type,
                                           content_type)

    else:
        errors.append(_('There was an error uploading your preview.'))

    if errors:
        upload_hash = ''

    return {'upload_hash': upload_hash, 'errors': errors}
开发者ID:bearstech,项目名称:zamboni,代码行数:18,代码来源:views.py


示例11: test_upload_type_not_recognized

 def test_upload_type_not_recognized(self):
     with self.assertRaises(ValueError):
         check_upload([], 'graphic', 'image/jpg')
开发者ID:jamesthechamp,项目名称:zamboni,代码行数:3,代码来源:test_utils_.py


示例12: test_not_valid

 def test_not_valid(self):
     with self.assertRaises(ValueError):
         check_upload([], 'graphic', 'image/jpg')
开发者ID:AALEKH,项目名称:zamboni,代码行数:3,代码来源:test_utils_.py


示例13: test_valid

 def test_valid(self):
     with storage.open(self.preview_image()) as f:
         errors, hash = check_upload(f, 'preview', 'image/png')
         assert not errors
开发者ID:AALEKH,项目名称:zamboni,代码行数:4,代码来源:test_utils_.py


示例14: test_valid

 def test_valid(self):
     with storage.open(get_image_path('preview.jpg')) as f:
         errors, hash = check_upload(f, 'preview', 'image/png')
         assert not errors
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:4,代码来源:test_utils_.py



注:本文中的mkt.developers.utils.check_upload函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.uri_to_pk函数代码示例发布时间:2022-05-27
下一篇:
Python test_views_payments.setup_payment_account函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap