Closed tssajo closed 6 years ago
Hi @tssajo - sorry you're having problems with the API client.
The documentation for this method is essentially the b2_list_file_names API reference you link to, but I agree that more contextual documentation in the Go library would help. I'll try to work as much of the API documentation in as possible.
The prefix and delimiter options are new (or at least weren't in the original description of the API when I implemented this call). I'll add them as a new method to avoid breaking existing code.
Regarding the main problem of listing pages of more than 32 files: I've not seen this myself and have used the code in the past to do exactly what you describe: page through large buckets to find all the files. I'll do some investigation and try to reproduce the issue on windows (I only have access to windows 8 and 10, so I may need to come back to you with an extended example to test on your system if they don't show the same behaviour).
From testing, I can confirm the following:
I am using MacOS, so it's possible there is some difference with Windows. I think this is unlikely however, since the problem you are reporting seems to occur with the API calls themselves, which shouldn't be any different on Windows.
I have added a function to the apitest.go
example here:
https://github.com/kothar/go-backblaze/blob/list_paging/apitest/apitest.go#L120
This uploads 40 files, lists them and checks that paging 10 files at a time also produces the same result. Can you checkout this branch if you are still having problems and run the test on your setup to determine if it's something specific to Windows 7? I will run the same on Windows 10 when I next have access to a system.
Closing as no further info
Hello,
I have several issues with the
func (b *Bucket) ListFileNames(startFileName string, maxFileCount int) (*ListFilesResponse, error)
function.First of all, it is nowhere documented nor an example is given on how to walk through all the files in a Bucket by using the "paging" mechanism. I managed to figure this out: First I call the function with startFileName = "" and then if the returned ListFilesResponse.NextFileName != "" then I call the function with that string again. Am I doing it right? I believe so.
Anyhow, it is not documented (or I just didn't find it anywhere) that the maxFileCount parameter cannot be larger than 32. Because if I set it to anything higher than 32 then some objects (files) in the Bucket are just silently skipped! This is happening with Go 1.8.4 on Windows 7. Note, that I noticed in one of your source files that you call this function with maxFileCount = 100 and I am wondering how did that work for you? Maybe it is a limitation on Windows only???
Another serious issues is that even if I call the function with maxFileCount = 32 (or lower, e.g. I tried with 24) then total number of the returned files returned from one of my B2 Buckets were 4,745 while the BackBlaze B2 web interface tells me that there are a total of 4,754 files in that Bucket! What could be causing this discrepancy? I really need to get a list of ALL files in the bucket without skipping anything.
Yet another issue is this: You do not implement the optional delimiter parameter. I read in the BackBlaze B2 API documentation that I can optionally provide a delimiter parameter to the
b2_list_file_names
API call and this can be used to get a list of "directories" only (in their example: photos/). See their examples here: https://www.backblaze.com/b2/docs/b2_list_file_names.html -- because this is not implemented in your library, I must walk through all(!) objects which is a pain because of the above mentioned issues (maxFileCount cannot be higher than 32; some files are being skipped).I hope that your can eventually improve your implementation by fixing the issues I mentioned here.
Thank you!