blob: 39134c9794193521bb01aae59f53ceeb45dec4ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Abstract injector class for GS requests."""
class FileNotFoundError(Exception):
"""Thrown by a subclass of CloudBucket when a file is not found."""
pass
class BaseCloudBucket(object):
"""An abstract base class for working with GS."""
def UploadFile(self, path, contents, content_type):
"""Uploads a file to GS.
Args:
path: where in GS to upload the file.
contents: the contents of the file to be uploaded.
content_type: the MIME Content-Type of the file.
"""
raise NotImplementedError
def DownloadFile(self, path):
"""Downsloads a file from GS.
Args:
path: the location in GS to download the file from.
Returns:
String contents of the file downloaded.
Raises:
bucket_injector.NotFoundException: if the file is not found.
"""
raise NotImplementedError
def UpdateFile(self, path, contents):
"""Uploads a file to GS.
Args:
path: location of the file in GS to update.
contents: the contents of the file to be updated.
"""
raise NotImplementedError
def RemoveFile(self, path):
"""Removes a file from GS.
Args:
path: the location in GS to download the file from.
"""
raise NotImplementedError
def FileExists(self, path):
"""Checks if a file exists in GS.
Args:
path: the location in GS of the file.
Returns:
boolean representing whether the file exists in GS.
"""
raise NotImplementedError
def GetImageURL(self, path):
"""Gets a URL to an item in GS from its path.
Args:
path: the location in GS of a file.
Returns:
an url to a file in GS.
Raises:
bucket_injector.NotFoundException: if the file is not found.
"""
raise NotImplementedError
def GetAllPaths(self, prefix):
"""Gets paths to files in GS that start with a prefix.
Args:
prefix: the prefix to filter files in GS.
Returns:
a generator of paths to files in GS.
"""
raise NotImplementedError
|