Skip to content

Commit

Permalink
better writing on last post
Browse files Browse the repository at this point in the history
  • Loading branch information
Victordgrandis committed Jun 27, 2024
1 parent c0570d2 commit ba5684a
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 41 deletions.
14 changes: 7 additions & 7 deletions content/posts/list-firebase-storage-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ date = 2024-06-27T17:35:23-03:00
draft = false
+++

Hi, today I want to share with you how I list all the files in certain folder of firebase storage and return them as an array. I this case only the files that are on the top level of that folder, and not the files inside a second folder.
Hi, today I want to show you how to list all the files in a particular folder of a Firebase storage and return them as an array. In this case only the files that are on the top level of that folder, and not the files inside a second folder.

### Dependencies

The package is ["cloud.google.com/go/storage"](https://pkg.go.dev/firebase.google.com/go/storage). You can install it using `go get cloud.google.com/go/storage`

### Why is this useful?

I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step. And then I took the returning array to delete over some conditions.
I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step, then I took the returned array to delete the files listed over some conditions.

But there are lots of situations where you read all the files in a foder, and having the list function on the toolbox may be useful for some of you.

Expand Down Expand Up @@ -73,15 +73,15 @@ For listing files we are going to use:
&storage.Query({prefix: "prefix"})
```

That you can find on package [docs](https://pkg.go.dev/firebase.google.com/go/storage), although I found very little examples about it.
This can be found in the [docs](https://pkg.go.dev/firebase.google.com/go/storage) package, although I found very few examples.

Since I wanted only the files that were on the first folder, and not inside a second folder, I will be splitting the name of the file and taking only the ones whose split name array length were equal to 2.
Since I only wanted the files that were in the top folder, and not in a second folder, I will split the name of the file and take only those whose split name array length was equal to 2.

### Limitations

As we are using a query that uses a string as prefix for selecting the folder we want to list, we can have the issue of returning more than one folder, since various folder names may fit the filter we are using.
Since we are using a query that uses a string as a prefix to select the folder we want to list, we may have the problem of returning more than one folder, as different folder names may match the filter we are using.

For example, if we have a folder called “1” (that was my case since my folders names were clients IDs), and we use that as a filter, our function may return also the content of the “10” folder. So we have to be careful of filtering manually after.
For example, if we have a folder called "1" (this was my case, since my folder names were client IDs) and we use that as a filter, our function may also return the contents of folder "10". So we have to be careful to filter manually afterwards.

### The listing function

Expand Down Expand Up @@ -128,4 +128,4 @@ func ListFiles(clientId string) []string {

```

And thats it! thanks for reaching the end.
And that was it! Hope you found it useful.
2 changes: 1 addition & 1 deletion public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="description" content="">
<meta name="author" content="">
<link rel="canonical" href="https://victordgrandis.github.io/blog/404.html">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.b609c58d5c11bb90b1a54e04005d74ad1ddf22165eb79f5533967e57df9c3b50.css" integrity="sha256-tgnFjVwRu5CxpU4EAF10rR3fIhZet59VM5Z&#43;V9&#43;cO1A=" rel="preload stylesheet" as="style">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.fc220c15db4aef0318bbf30adc45d33d4d7c88deff3238b23eb255afdc472ca6.css" integrity="sha256-/CIMFdtK7wMYu/MK3EXTPU18iN7/MjiyPrJVr9xHLKY=" rel="preload stylesheet" as="style">
<link rel="icon" href="https://victordgrandis.github.io/blog/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="https://victordgrandis.github.io/blog/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://victordgrandis.github.io/blog/favicon-32x32.png">
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/categories/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="description" content="">
<meta name="author" content="">
<link rel="canonical" href="https://victordgrandis.github.io/blog/categories/">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.b609c58d5c11bb90b1a54e04005d74ad1ddf22165eb79f5533967e57df9c3b50.css" integrity="sha256-tgnFjVwRu5CxpU4EAF10rR3fIhZet59VM5Z&#43;V9&#43;cO1A=" rel="preload stylesheet" as="style">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.fc220c15db4aef0318bbf30adc45d33d4d7c88deff3238b23eb255afdc472ca6.css" integrity="sha256-/CIMFdtK7wMYu/MK3EXTPU18iN7/MjiyPrJVr9xHLKY=" rel="preload stylesheet" as="style">
<link rel="icon" href="https://victordgrandis.github.io/blog/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="https://victordgrandis.github.io/blog/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://victordgrandis.github.io/blog/favicon-32x32.png">
Expand Down
6 changes: 3 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta name="description" content="">
<meta name="author" content="">
<link rel="canonical" href="https://victordgrandis.github.io/blog/">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.b609c58d5c11bb90b1a54e04005d74ad1ddf22165eb79f5533967e57df9c3b50.css" integrity="sha256-tgnFjVwRu5CxpU4EAF10rR3fIhZet59VM5Z&#43;V9&#43;cO1A=" rel="preload stylesheet" as="style">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.fc220c15db4aef0318bbf30adc45d33d4d7c88deff3238b23eb255afdc472ca6.css" integrity="sha256-/CIMFdtK7wMYu/MK3EXTPU18iN7/MjiyPrJVr9xHLKY=" rel="preload stylesheet" as="style">
<link rel="icon" href="https://victordgrandis.github.io/blog/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="https://victordgrandis.github.io/blog/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://victordgrandis.github.io/blog/favicon-32x32.png">
Expand Down Expand Up @@ -174,9 +174,9 @@ <h2 class="entry-hint-parent">How to list Firebase Storage files in Golang
</h2>
</header>
<div class="entry-content">
<p>Hi, today I want to share with you how I list all the files in certain folder of firebase storage and return them as an array. I this case only the files that are on the top level of that folder, and not the files inside a second folder.
<p>Hi, today I want to show you how to list all the files in a particular folder of a Firebase storage and return them as an array. In this case only the files that are on the top level of that folder, and not the files inside a second folder.
Dependencies The package is “cloud.google.com/go/storage”. You can install it using go get cloud.google.com/go/storage
Why is this useful? I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step....</p>
Why is this useful? I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step, then I took the returned array to delete the files listed over some conditions....</p>
</div>
<footer class="entry-footer"><span title='2024-06-27 17:35:23 -0300 -03'>June 27, 2024</span></footer>
<a class="entry-link" aria-label="post link to How to list Firebase Storage files in Golang" href="https://victordgrandis.github.io/blog/posts/list-firebase-storage-files/"></a>
Expand Down
4 changes: 2 additions & 2 deletions public/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<link>https://victordgrandis.github.io/blog/posts/list-firebase-storage-files/</link>
<pubDate>Thu, 27 Jun 2024 17:35:23 -0300</pubDate>
<guid>https://victordgrandis.github.io/blog/posts/list-firebase-storage-files/</guid>
<description>Hi, today I want to share with you how I list all the files in certain folder of firebase storage and return them as an array. I this case only the files that are on the top level of that folder, and not the files inside a second folder.
<description>Hi, today I want to show you how to list all the files in a particular folder of a Firebase storage and return them as an array. In this case only the files that are on the top level of that folder, and not the files inside a second folder.
Dependencies The package is &amp;ldquo;cloud.google.com/go/storage&amp;rdquo;. You can install it using go get cloud.google.com/go/storage
Why is this useful? I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step.</description>
Why is this useful? I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step, then I took the returned array to delete the files listed over some conditions.</description>
</item>
<item>
<title>Creating Shareable PDF Reports with Kotlin and iText from RecyclerView Data</title>
Expand Down
2 changes: 1 addition & 1 deletion public/posts/hotjar-angular/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Include Hotjar in your project First we need to include the tracking code in our index.">
<meta name="author" content="">
<link rel="canonical" href="https://victordgrandis.github.io/blog/posts/hotjar-angular/">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.b609c58d5c11bb90b1a54e04005d74ad1ddf22165eb79f5533967e57df9c3b50.css" integrity="sha256-tgnFjVwRu5CxpU4EAF10rR3fIhZet59VM5Z&#43;V9&#43;cO1A=" rel="preload stylesheet" as="style">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.fc220c15db4aef0318bbf30adc45d33d4d7c88deff3238b23eb255afdc472ca6.css" integrity="sha256-/CIMFdtK7wMYu/MK3EXTPU18iN7/MjiyPrJVr9xHLKY=" rel="preload stylesheet" as="style">
<link rel="icon" href="https://victordgrandis.github.io/blog/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="https://victordgrandis.github.io/blog/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://victordgrandis.github.io/blog/favicon-32x32.png">
Expand Down
6 changes: 3 additions & 3 deletions public/posts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="description" content="Posts - Victor De Grandis Site">
<meta name="author" content="">
<link rel="canonical" href="https://victordgrandis.github.io/blog/posts/">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.b609c58d5c11bb90b1a54e04005d74ad1ddf22165eb79f5533967e57df9c3b50.css" integrity="sha256-tgnFjVwRu5CxpU4EAF10rR3fIhZet59VM5Z&#43;V9&#43;cO1A=" rel="preload stylesheet" as="style">
<link crossorigin="anonymous" href="/blog/assets/css/stylesheet.fc220c15db4aef0318bbf30adc45d33d4d7c88deff3238b23eb255afdc472ca6.css" integrity="sha256-/CIMFdtK7wMYu/MK3EXTPU18iN7/MjiyPrJVr9xHLKY=" rel="preload stylesheet" as="style">
<link rel="icon" href="https://victordgrandis.github.io/blog/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="https://victordgrandis.github.io/blog/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://victordgrandis.github.io/blog/favicon-32x32.png">
Expand Down Expand Up @@ -158,9 +158,9 @@ <h2 class="entry-hint-parent">How to list Firebase Storage files in Golang
</h2>
</header>
<div class="entry-content">
<p>Hi, today I want to share with you how I list all the files in certain folder of firebase storage and return them as an array. I this case only the files that are on the top level of that folder, and not the files inside a second folder.
<p>Hi, today I want to show you how to list all the files in a particular folder of a Firebase storage and return them as an array. In this case only the files that are on the top level of that folder, and not the files inside a second folder.
Dependencies The package is “cloud.google.com/go/storage”. You can install it using go get cloud.google.com/go/storage
Why is this useful? I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step....</p>
Why is this useful? I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step, then I took the returned array to delete the files listed over some conditions....</p>
</div>
<footer class="entry-footer"><span title='2024-06-27 17:35:23 -0300 -03'>June 27, 2024</span></footer>
<a class="entry-link" aria-label="post link to How to list Firebase Storage files in Golang" href="https://victordgrandis.github.io/blog/posts/list-firebase-storage-files/"></a>
Expand Down
4 changes: 2 additions & 2 deletions public/posts/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<link>https://victordgrandis.github.io/blog/posts/list-firebase-storage-files/</link>
<pubDate>Thu, 27 Jun 2024 17:35:23 -0300</pubDate>
<guid>https://victordgrandis.github.io/blog/posts/list-firebase-storage-files/</guid>
<description>Hi, today I want to share with you how I list all the files in certain folder of firebase storage and return them as an array. I this case only the files that are on the top level of that folder, and not the files inside a second folder.
<description>Hi, today I want to show you how to list all the files in a particular folder of a Firebase storage and return them as an array. In this case only the files that are on the top level of that folder, and not the files inside a second folder.
Dependencies The package is &amp;ldquo;cloud.google.com/go/storage&amp;rdquo;. You can install it using go get cloud.google.com/go/storage
Why is this useful? I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step.</description>
Why is this useful? I myself had the necessity of cleaning the storage folder of old files left there, so listing them is the first step, then I took the returned array to delete the files listed over some conditions.</description>
</item>
<item>
<title>Creating Shareable PDF Reports with Kotlin and iText from RecyclerView Data</title>
Expand Down
Loading

0 comments on commit ba5684a

Please sign in to comment.