def upload_photos(self, photos): upload_files = self.get_uploads() if upload_files is not None and len(upload_files) > 0: files_count = len(upload_files) logger.info('no of files uploaded ' + str(files_count)) for x in xrange(files_count): blob_info = upload_files[x] media_obj = Media() media_obj.name = self.form.media.__getitem__(x).data['name'] media_obj.status = self.form.media.__getitem__( x).data['status'] media_obj.link = blob_info.key() photos.append(media_obj) logger.info('Link to picture file ' + media_obj.name + ', ' + images.get_serving_url(media_obj.link)) return photos
def upload_photos(self, key): upload_files = self.get_uploads() if upload_files is not None and len(upload_files) > 0: files_count = len(upload_files) logger.info('no of files uploaded ' + str(files_count)) for x in xrange(files_count): blob_info = upload_files[x] media_obj = Media() media_obj.name = self.form.media.__getitem__(x).data['name'] media_obj.type = constants.PHOTO media_obj.status = self.form.media.__getitem__(x).data['status'] media_obj.primary = self.form.media.__getitem__(x).data['primary'] media_obj.link = blob_info.key() media_obj.url = images.get_serving_url(blob_info.key()) media_obj.entity_id = key media_obj.entity_type = constants.PLAYGROUND self.mediaDao.persist(media_obj) logger.info('Link to picture file ' + media_obj.name + ', ' + images.get_serving_url(media_obj.link))