|
16 | 16 | * this source code or binaries.
|
17 | 17 | */
|
18 | 18 |
|
19 |
| -import java.io.IOException; |
20 |
| - |
21 | 19 | import org.apache.http.impl.client.CloseableHttpClient;
|
22 | 20 | import org.apache.http.util.EntityUtils;
|
23 | 21 |
|
| 22 | +import java.io.IOException; |
| 23 | + |
24 | 24 | import synapticloop.b2.exception.B2ApiException;
|
25 | 25 | import synapticloop.b2.response.B2AuthorizeAccountResponse;
|
26 | 26 | import synapticloop.b2.response.B2ListFilesResponse;
|
27 | 27 |
|
28 | 28 | /**
|
29 | 29 | * <p>Lists the names of all files in a bucket, starting at a given name.</p>
|
30 |
| - * |
| 30 | + * <p> |
31 | 31 | * <p>This call returns at most 1000 file names, but it can be called repeatedly to scan through all of the file names in a bucket. Each time you call, it returns an "endFileName" that can be used as the starting point for the next call.</p>
|
32 | 32 | * <p>There may be many file versions for the same name, but this call will return each name only once. If you want all of the versions, use b2_list_file_versions instead.</p>
|
33 |
| - * |
34 |
| - * |
35 |
| - * This is the interaction class for the <strong>b2_list_file_names</strong> api calls, this was |
| 33 | + * <p> |
| 34 | + * <p> |
| 35 | + * This is the interaction class for the <strong>b2_list_file_names</strong> api calls, this was |
36 | 36 | * generated from the backblaze api documentation - which can be found here:
|
37 |
| - * |
| 37 | + * <p> |
38 | 38 | * <a href="http://www.backblaze.com/b2/docs/b2_list_file_names.html">http://www.backblaze.com/b2/docs/b2_list_file_names.html</a>
|
39 |
| - * |
| 39 | + * |
40 | 40 | * @author synapticloop
|
41 | 41 | */
|
42 | 42 | public class B2ListFileNamesRequest extends BaseB2Request {
|
43 |
| - private static final String B2_LIST_FILE_NAMES = BASE_API_VERSION + "b2_list_file_versions"; |
| 43 | + private static final String B2_LIST_FILE_NAMES = BASE_API_VERSION + "b2_list_file_versions"; |
44 | 44 |
|
45 |
| - private static final int DEFAULT_MAX_FILE_COUNT = 100; |
| 45 | + private static final int DEFAULT_MAX_FILE_COUNT = 100; |
46 | 46 |
|
47 |
| - /** |
48 |
| - * Create a list file names request, this will return at most the default |
49 |
| - * number of files, which is 100. |
50 |
| - * |
51 |
| - * @param client the HTTP client to use |
52 |
| - * @param b2AuthorizeAccountResponse the authorize account response |
53 |
| - * @param bucketId the id of the bucket to list |
54 |
| - */ |
55 |
| - public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, String bucketId) { |
56 |
| - this(client, b2AuthorizeAccountResponse, bucketId, null, DEFAULT_MAX_FILE_COUNT); |
57 |
| - } |
| 47 | + /** |
| 48 | + * Create a list file names request, this will return at most the default |
| 49 | + * number of files, which is 100. |
| 50 | + * |
| 51 | + * @param client the HTTP client to use |
| 52 | + * @param b2AuthorizeAccountResponse the authorize account response |
| 53 | + * @param bucketId the id of the bucket to list |
| 54 | + */ |
| 55 | + public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, String bucketId) { |
| 56 | + this(client, b2AuthorizeAccountResponse, bucketId, null, DEFAULT_MAX_FILE_COUNT, null, null); |
| 57 | + } |
58 | 58 |
|
59 |
| - /** |
60 |
| - * Create a list file names request returning up to the maxFileCount number of results |
61 |
| - * |
62 |
| - * @param client the HTTP client to use |
63 |
| - * @param b2AuthorizeAccountResponse the authorize account response |
64 |
| - * @param bucketId the id of the bucket to list |
65 |
| - * @param maxFileCount The maximum number of files to return from this call. |
66 |
| - * The default value is 100, and the maximum allowed is 1000. |
67 |
| - */ |
68 |
| - public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, String bucketId, Integer maxFileCount) { |
69 |
| - this(client, b2AuthorizeAccountResponse, bucketId, null, maxFileCount); |
70 |
| - } |
| 59 | + /** |
| 60 | + * Create a list file names request returning up to the maxFileCount number of results |
| 61 | + * |
| 62 | + * @param client the HTTP client to use |
| 63 | + * @param b2AuthorizeAccountResponse the authorize account response |
| 64 | + * @param bucketId the id of the bucket to list |
| 65 | + * @param maxFileCount The maximum number of files to return from this call. |
| 66 | + * The default value is 100, and the maximum allowed is 1000. |
| 67 | + */ |
| 68 | + public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, String bucketId, Integer maxFileCount) { |
| 69 | + this(client, b2AuthorizeAccountResponse, bucketId, null, maxFileCount, null, null); |
| 70 | + } |
71 | 71 |
|
72 |
| - /** |
73 |
| - * Create a list file names request returning up to the maxFileCount number of results |
74 |
| - * |
75 |
| - * @param client the HTTP client to use |
76 |
| - * @param b2AuthorizeAccountResponse the authorize account response |
77 |
| - * @param bucketId the id of the bucket to list |
78 |
| - * @param startFileName The first file name to return. If there is a file |
79 |
| - * with this name, it will be returned in the list. If not, the first |
80 |
| - * file name after this the first one after this name. |
81 |
| - * @param maxFileCount The maximum number of files to return from this call. |
82 |
| - * The default value is 100, and the maximum allowed is 1000. |
83 |
| - */ |
84 |
| - public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, String bucketId, String startFileName, Integer maxFileCount) { |
85 |
| - super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_LIST_FILE_NAMES); |
| 72 | + /** |
| 73 | + * Create a list file names request returning up to the maxFileCount number of results |
| 74 | + * |
| 75 | + * @param client the HTTP client to use |
| 76 | + * @param b2AuthorizeAccountResponse the authorize account response |
| 77 | + * @param bucketId the id of the bucket to list |
| 78 | + * @param startFileName The first file name to return. If there is a file |
| 79 | + * with this name, it will be returned in the list. If not, the first |
| 80 | + * file name after this the first one after this name. |
| 81 | + * @param maxFileCount The maximum number of files to return from this call. |
| 82 | + * @param prefix Files returned will be limited to those with the given prefix. Defaults to the empty string, which matches all files. |
| 83 | + * @param delimiter Files returned will be limited to those within the top folder, or any one subfolder. Defaults to NULL. Folder names will also be returned. The delimiter character will be used to "break" file names into folders. |
| 84 | + */ |
| 85 | + public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, String bucketId, String startFileName, Integer maxFileCount, String prefix, String delimiter) { |
| 86 | + super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_LIST_FILE_NAMES); |
86 | 87 |
|
87 |
| - this.addProperty(B2RequestProperties.KEY_BUCKET_ID, bucketId); |
| 88 | + this.addProperty(B2RequestProperties.KEY_BUCKET_ID, bucketId); |
88 | 89 |
|
89 |
| - if(null != startFileName) { |
90 |
| - this.addProperty(B2RequestProperties.KEY_START_FILE_NAME, startFileName); |
91 |
| - } |
| 90 | + if(null != startFileName) { |
| 91 | + this.addProperty(B2RequestProperties.KEY_START_FILE_NAME, startFileName); |
| 92 | + } |
| 93 | + if(null != prefix) { |
| 94 | + this.addProperty(B2RequestProperties.KEY_PREFIX, prefix); |
| 95 | + } |
| 96 | + if(null != delimiter) { |
| 97 | + this.addProperty(B2RequestProperties.KEY_DELIMITER, delimiter); |
| 98 | + } |
92 | 99 |
|
93 |
| - this.addProperty(B2RequestProperties.KEY_MAX_FILE_COUNT, maxFileCount); |
94 |
| - } |
| 100 | + this.addProperty(B2RequestProperties.KEY_MAX_FILE_COUNT, maxFileCount); |
| 101 | + } |
95 | 102 |
|
96 |
| - /** |
97 |
| - * Return the list file names response |
98 |
| - * |
99 |
| - * @return the list file names response |
100 |
| - * |
101 |
| - * @throws B2ApiException if something went wrong |
102 |
| - * @throws IOException if there was an error communicating with the API service |
103 |
| - */ |
104 |
| - public B2ListFilesResponse getResponse() throws B2ApiException, IOException { |
105 |
| - return new B2ListFilesResponse(EntityUtils.toString(executePost().getEntity())); |
106 |
| - } |
| 103 | + /** |
| 104 | + * Return the list file names response |
| 105 | + * |
| 106 | + * @return the list file names response |
| 107 | + * @throws B2ApiException if something went wrong |
| 108 | + * @throws IOException if there was an error communicating with the API service |
| 109 | + */ |
| 110 | + public B2ListFilesResponse getResponse() throws B2ApiException, IOException { |
| 111 | + return new B2ListFilesResponse(EntityUtils.toString(executePost().getEntity())); |
| 112 | + } |
107 | 113 | }
|
0 commit comments