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