def db_backup_all(backup_dir='/backup'): """ rds all backup """ # DBバックアップ for db in env.databases: #print db db_backup(db["name"], db["name"], db["password"], backup_dir=backup_dir) # S3に転送 s3.put(env.s3['db'], backup_dir)
def wrapper(*iargs, **ikwargs): pk = f'{func.__name__}-{hashMD5(*iargs)}' refs = findReferenceByPk(pk) bucket = 'hellovictorlee-cache' if refs: keys = [] for ref in refs: keys = keys + ref['keys'] # TODO: keys => batch get return s3.get(bucket=bucket, key=keys[0]) body = func(*iargs, **ikwargs) key = f'{func.__name__}/{uuid.uuid4().hex}.json' s3.put(body=body, bucket=bucket, key=key) dynamodb.put({'pk': pk, 'sk': f'{getUnix()}', 'keys': [key]}) return body
def POST(self, request, response): path = request.path[1:] folder = path.split('/') if self.has_access(response, path): file = request.files['file'] mimetype = from_buffer(file.stream.read(1024), mime=True) s3.put(path, file, response.user, mimetype) response.data = 'That probably worked...' else: response.data = 'Permission denied in this folder.' response.status_code = 401 return response
def user_image(user): if request.method == 'GET': if s3.exists(personal(path(user))): obj = s3.get(personal(path(user))) return send_file(obj['Body'], mimetype=obj['ContentType']) elif s3.exists(original(path(user))): obj = s3.get(original(path(user))) return send_file(obj['Body'], mimetype=obj['ContentType']) else: return Response(missing, content_type='image/svg+xml') elif request.method == 'POST' and verify_token(request.args.get('token')): image = request.files['file'] mimetype = from_buffer(image.stream.read(1024), mime=True) s3.put(personal(path(user)), image, mimetype) return 'Personal image uploaded successfully' elif request.method == 'DELETE' and verify_token(request.args.get('token')): s3.delete(personal(path(user))) return 'Personal image deleted successfully' else: return 'You can only edit you own picture!'
def _file_put(backup_path): s3.put(env.s3['file'], backup_path)