Esempio n. 1
0
    def post(self):
        image_file = self.request.POST.get("pic", None)
        file_obj = self.request.get("pic", None)
        if not isinstance(image_file, cgi.FieldStorage):
            return json_response(self.response, {}, ERROR, 'Select image file')

        key = self.request.get('key')
        e = ndb.Key(urlsafe=key).get()

        file_name = image_file.filename
        bucket_path = '/designer_frames/%s' % (file_name)
        bucket_path = bucket_path.lower()
        serving_url = ''
        upload_file(file_obj, bucket_path)
        try:
            logging.info('create_gs_key')
            bucket_key = blobstore.create_gs_key('/gs' + bucket_path)
            logging.info(bucket_key)
            logging.info('serving_url')
            if self.DEV:
                serving_url = images.get_serving_url(bucket_key)
            else:
                file_name = file_name.replace(' ', '%20').lower()
                serving_url = 'https://storage.googleapis.com/designer_frames/%s' % (
                    file_name)
            logging.info(serving_url)
        except Exception, msg:
            logging.error(msg)
            return json_response(self.response, {}, WARNING, 'Try again')
Esempio n. 2
0
    def post(self):
        image_file = self.request.POST.get("pic", None)
        file_obj = self.request.get("pic", None)
        if not isinstance(image_file, cgi.FieldStorage):
            return json_response(self.response, {}, ERROR, 'Select image file')

        product_key = ndb.Key(urlsafe=self.request.get('p'))
        file_name = image_file.filename
        bucket_path = '/designer_canvas/%s' % (file_name)
        bucket_path = bucket_path.lower()
        serving_url = ''
        upload_file(file_obj, bucket_path)
        try:
            bucket_key = blobstore.create_gs_key('/gs' + bucket_path)
            serving_url = images.get_serving_url(bucket_key)
        except Exception, msg:
            logging.error(msg)
            return json_response(self.response, {}, WARNING, 'Try again')
Esempio n. 3
0
class GetProductLiveInfo(ActionSupport):
    def get(self):
        if not self.request.get('k'):
            return json_response(self.response, {}, ERROR, '')

        p = ndb.Key(urlsafe=self.request.get('k')).get()
        d = {
            'k': self.request.get('k'),
            'promo_img': p.promo_img,
            'promo_buckt_key': p.promo_buckt_key,
            'promo_product_bg_img': p.promo_product_bg_img,
            'promo_product_bg_key': p.promo_product_bg_key,
            'promo_text': p.promo_text,
            'promo_sequence': p.promo_sequence
        }
        return json_response(self.response, d, SUCCESS, '')

    def post(self):
        serving_url = ''
        p = ndb.Key(urlsafe=self.request.get('k')).get()
        sequence = self.request.get('sequence')
        p.promo_sequence = int(sequence) if sequence else 0
        p.promo_text = self.request.get('promo_text')

        image_file = self.request.POST.get("pic", None)
        file_obj = self.request.get("pic", None)
        if not p.promo_img and isinstance(image_file, cgi.FieldStorage):
            file_name = image_file.filename
            bucket_path = '/product_sponsor/%s' % (file_name)
            bucket_path = bucket_path.lower()
            serving_url = ''
            upload_file(file_obj, bucket_path)
            try:
                bucket_key = blobstore.create_gs_key('/gs' + bucket_path)
                serving_url = images.get_serving_url(bucket_key)
                p.promo_img = serving_url
                p.promo_buckt_key = bucket_key
            except Exception, msg:
                logging.error(msg)

        image_file = self.request.POST.get("bg", None)
        file_obj = self.request.get("bg", None)
        if not p.promo_product_bg_img and isinstance(image_file,
                                                     cgi.FieldStorage):
            file_name = image_file.filename
            bucket_path = '/product_bg/%s' % (file_name)
            bucket_path = bucket_path.lower()
            upload_file(file_obj, bucket_path)
            try:
                bucket_key = blobstore.create_gs_key('/gs' + bucket_path)
                serving_url = images.get_serving_url(bucket_key)
                p.promo_product_bg_img = serving_url
                p.promo_product_bg_key = bucket_key
            except Exception, msg:
                logging.error(msg)
Esempio n. 4
0
    def post(self):
        image_file = self.request.POST.get("pic", None)
        file_obj = self.request.get("pic", None)
        if not isinstance(image_file, cgi.FieldStorage):
            return json_response(self.response, {}, ERROR, 'Select image file')

        file_name = image_file.filename
        bucket_path = '/designer_textptrn/ready_design/%s' % (file_name)
        bucket_path = bucket_path.lower()
        upload_file(file_obj, bucket_path)
        serving_url = ''
        try:
            bucket_key = blobstore.create_gs_key('/gs' + bucket_path)
            serving_url = images.get_serving_url(bucket_key)
            e = ReadyDesignStaticImage.get_obj()
            e.img_url.append(serving_url)
            e.img_key.append(bucket_key)
            e.put()
        except Exception, msg:
            logging.error(msg)
Esempio n. 5
0
    def post(self):
        serving_url = ''
        p = ndb.Key(urlsafe=self.request.get('k')).get()
        sequence = self.request.get('sequence')
        p.promo_sequence = int(sequence) if sequence else 0
        p.promo_text = self.request.get('promo_text')

        image_file = self.request.POST.get("pic", None)
        file_obj = self.request.get("pic", None)
        if not p.promo_img and isinstance(image_file, cgi.FieldStorage):
            file_name = image_file.filename
            bucket_path = '/product_sponsor/%s' % (file_name)
            bucket_path = bucket_path.lower()
            serving_url = ''
            upload_file(file_obj, bucket_path)
            try:
                bucket_key = blobstore.create_gs_key('/gs' + bucket_path)
                serving_url = images.get_serving_url(bucket_key)
                p.promo_img = serving_url
                p.promo_buckt_key = bucket_key
            except Exception, msg:
                logging.error(msg)