firebase-console https://www.e-learn.cn/tag/firebase-console zh-hans How can I order the documents in Firestore? https://www.e-learn.cn/topic/4106525 <span>How can I order the documents in Firestore?</span> <span><span lang="" about="/user/52" typeof="schema:Person" property="schema:name" datatype="">◇◆丶佛笑我妖孽</span></span> <span>2021-02-16 14:19:33</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>How can I order the documents in Firestore? It looks like Firestore lists documents in alphabetic order by the ID I let Firestore automatically create. But I don't want that. I just want to see my newly added document added as the last document in the collection. How do I do that? Should I create my own alphabetic ID's?</p> <p>Example of my collection in Firestore:</p> <p><img alt="Example of my collection in Firestore" class="b-lazy" data-src="https://i.stack.imgur.com/0tC24.png" data-original="https://i.stack.imgur.com/0tC24.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /></p> <br /><h3>回答1:</h3><br /><p>Firestore is meant to scale massively. At that scale, it doesn't matter what order the documents appear in the console, because the console is useless for viewing massive numbers of documents within a collection.</p> <p>If you still need an ordering in the console, you will have to come up with document IDs of your own.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/50447426/how-can-i-order-the-documents-in-firestore</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/javascript" hreflang="zh-hans">javascript</a></div> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/google-cloud-firestore" hreflang="zh-hans">google-cloud-firestore</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Tue, 16 Feb 2021 06:19:33 +0000 ◇◆丶佛笑我妖孽 4106525 at https://www.e-learn.cn How to get firebase real-time database usage programmatically https://www.e-learn.cn/topic/4056138 <span>How to get firebase real-time database usage programmatically</span> <span><span lang="" about="/user/15" typeof="schema:Person" property="schema:name" datatype="">假装没事ソ</span></span> <span>2021-02-05 11:42:33</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Is there any API available for getting real-time database usage. We need to show usage and related info on our dashboard and my client don't want to visite firebase consol and option for the upgrade or downgrade plan programmatically</p> <br /><h3>回答1:</h3><br /><p>There is currently no API for this. You may file a feature request here.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/52620717/how-to-get-firebase-real-time-database-usage-programmatically</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-realtime-database" hreflang="zh-hans">firebase-realtime-database</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Fri, 05 Feb 2021 03:42:33 +0000 假装没事ソ 4056138 at https://www.e-learn.cn how to add more than one android app to your firebase project? https://www.e-learn.cn/topic/4050260 <span>how to add more than one android app to your firebase project?</span> <span><span lang="" about="/user/241" typeof="schema:Person" property="schema:name" datatype="">落花浮王杯</span></span> <span>2021-02-04 21:08:19</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Is it possible to add more than one android app to the same project in the firebase console? I've been trying to find the answer and it seems like the interface has changed or I just can't find the right place to add an additional app to the project. basically i'd like to have more than one app listed here where it says "your apps":</p> <p></p> <p>maybe i'm missing something but as far as I understood this is the way to get a google-services.json file that I can use for FCM. (if this is the wrong way to go about that please do tell :))</p> <br /><h3>回答1:</h3><br /><p>Yes it is, you can add more than one app to your firebase project:</p> <p></p> <p></p> <p></p> <p></p> <p>in case you are missing firebase <strong>Add App</strong> button you can follow this:</p> <p></p> <p></p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/41415426/how-to-add-more-than-one-android-app-to-your-firebase-project</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Thu, 04 Feb 2021 13:08:19 +0000 落花浮王杯 4050260 at https://www.e-learn.cn How to completely disconnect an Android app from Firebase (in Android studio) https://www.e-learn.cn/topic/4016440 <span>How to completely disconnect an Android app from Firebase (in Android studio)</span> <span><span lang="" about="/user/125" typeof="schema:Person" property="schema:name" datatype="">僤鯓⒐⒋嵵緔</span></span> <span>2021-01-27 13:30:34</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I want to completely disconnect my app from Firebase. This question has been asked several times (e.g here). Most of the answers focus on disconnecting an app from Firebase <strong>within the Firebase console</strong> and not <strong>within Android studio</strong>.</p> <p>After disconnecting my app from the Firebase console. Everytime I try to reconnect the app to another Firebase project, an error balloon pops up stating that the app is already part of a Firebase project. I know this behaviour occurs because some files from the old Firebase project are still present. How do I get rid of them?</p> <br /><h3>回答1:</h3><br /><p>You should undo all the steps that you are instructed to perform in the manual integration. So, remove all Firebase dependencies from build.gradle, remove the Google Services plugin from the bottom of build.gradle, and remove the google-services.json file.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>Try these steps to remove Fire-base from Android Studio project.</p> <blockquote> <p>Delete <code>google-services.json</code> file from the Project (Find the file by Project view)</p> <p>Remove dependencies from Project-level <code>build.gradle</code> (/build.gradle)</p> </blockquote> <pre><code>buildscript { dependencies { // Remove this line classpath 'com.google.gms:google-services:4.2.0' } } </code></pre> <blockquote> <p>Remove all the Fire-base related dependencies from the project App-level <code>build.gradle</code> (//build.gradle) file</p> </blockquote> <pre><code>dependencies { // Remove this line implementation 'com.google.firebase:firebase-core:17.0.0' } </code></pre> <blockquote> <p>Remove the line below from the bottom of the App-level <code>build.gradle</code> (//build.gradle) file</p> </blockquote> <pre><code>apply plugin: 'com.google.gms.google-services' </code></pre> <blockquote> <p>Restart Android Studio</p> </blockquote> <br /><br /><br /><h3>回答3:</h3><br /><p>Try this, On the project level, delete the google-services.json file <br /><br />and then sync the project <br /></p> <br /><br /><br /><h3>回答4:</h3><br /><p>Try shutting down the Firebase project created with the package name of the connected application; although it doesn't delete at the same time and is scheduled for later. Don't link your android app with any other firebase app till the previous connected app has been deleted completely.</p> <br /><br /><br /><h3>回答5:</h3><br /><p>Do the following (If you want to Switch Firebase Data Sources): In Android Studio, Go to Tools&gt;Firebase, Choose any of the options such as Real time-database Click Connect to Firebase. You will get a warning that the App is already connected to Firebase. Click okay. Android Studio will open a Firebase console on a browser. Choose the Firebase App you want to you want to connect to. Done. </p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/51549554/how-to-completely-disconnect-an-android-app-from-firebase-in-android-studio</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/android" hreflang="zh-hans">android</a></div> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Wed, 27 Jan 2021 05:30:34 +0000 僤鯓⒐⒋嵵緔 4016440 at https://www.e-learn.cn Firebase Storage - Image preview is permenantly loading https://www.e-learn.cn/topic/4002509 <span>Firebase Storage - Image preview is permenantly loading</span> <span><span lang="" about="/user/167" typeof="schema:Person" property="schema:name" datatype="">半世苍凉</span></span> <span>2021-01-20 08:47:14</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I've started working with firebase storage and firebase functions recently. Right now I've been developing file upload from functions to storage .</p> <p>I've got it working (upload is done and file appears on the storage section), yet, the image, stays like this forever (loading forever on the right side):</p> <p></p> <p>I though that it was an error from my code. Yet, if I open Google Cloud Platform - Storage, the image appears and I can open it and preview it. </p> <p>In firebase storage, if I open the image (select on it and click open), it returns the following url: https://console.firebase.google.com/u/0/undefined</p> <p>What may I been doing wrong? Here's the code I'm using:</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>function uploadImage() { const newImageData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAgVBMVEX///8AAAAEBASAgIDr6+vw8PBYWFjU1NTGxsbz8/P29vb8/Py1tbVhYWHd3d1ra2vk5OS/v78pKSlTU1NOTk6Tk5OpqanNzc13d3dKSkplZWWbm5s5OTkfHx+NjY2GhoYcHBw9PT0TExOioqJ7e3soKCiurq5CQkI6OjoXFxcwMDAuPQWoAAAIJ0lEQVR4nO2daXuqPBCGVfYtIbKLgorLKf//B75ga2sPAdmS8F5n7m/VXgyPISGZzExWKwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAVy6wwlCZG/YUl+vamYLoy0lAkORWbdZNN/YUUVf8ju6bomx2Kq+mEBL5K0UVD9QNCdM0Vfds9QSQMnYTWaN1sEicMCRJ9+29QSCqp28HiftiqUkoU0TLaMDLsl8PbrtGWpY8zQ7QYCoE/pe3+ZusHogW9Yln2nxnVPfljW8t4l8go2zPQV7PPkCxa3kqOvOldr52NF4nVKNuYobxPsC1OoxVilu33ZINDQf1Rw2cO+mrOWBMhMD5w0ldziLnrQyeO+mpOfOdzZspZX03KcQGC2I+gNDC3ZkQ7IQLX6x0niW7fZd83ief7Pg7tH0JcfeIlQy+kcllCyk7/O/LUWIsiDbkVv9/bcv0Rqr+MVa//BR0Ob/++AstdKLuK8n4ZZCiKK4e7cikSez2iTjxm2DPjPj8e8wf1zWviXPqpPuHyeuqXb2ZK6WxaqJCuZe7m7qTTp1da6ty7prtbMoOOVro64VktonlmyFZUqB0NybQrkna7l1ndZIhc2k0xbESjdTEf63M7yBQ9bjO2Z+enamvCXcTCphG1zZ3YNSJ9OroJmRkM6UMOZmXPoppzWE4WEX1oY7Xmv1Fs7Zn9nl9gWt+/MTImNU2dprze+6GfmmYlRrY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91pQtBXHfZ12hUNn/mCFNZEaYxPY6YC5QnH9JSwhSl8qCRpFu9Pfb3Yh9M+zlLSmvAmTmGbL/uBoUfkFhY48dvDa30/wUV4I5HembMoLs7b6xGKISOE9Ce5p6qql3//XX3XY88RNVICllvbpM7Hk+WhOab8aps0nzIeRZSoZZQYWaIkyLMNNfnEbprtHAAmQCtlyL6OEq3Q34WRLcqPyb4V+RqlGVuHLMP3FEofXDPrhqsVPYIHM6xtQg86SZgZ1Kj21iWjEjVu3jL5Y3eOgEw3WK3l4vnrRVlx65qTXRFaWlGqJ/Fq1qivVUdKHMvyW3JXMJZPBs9W6BhyZ6YYZlrSW++wXHVIiaCpIg1EpO61F9syePK7fMokt8noekMWInb+rnRLzLgqu/ved3jw8tQePrq6dpp771eUDvPDA+TT25uo2Ho4v4V9n1gjvOXY6+U+P3E4OqC7K75w/DglSZymQftNyUGaxkly+ujtcOVSi7K3xF987KRXdh+jrsKn2OZK57Pl1KTkJLCaD7PejqHjcDwYsXXGyBBWs98WrBtvieWN89FkJucTkTDif9ysgTgKnDwZHMfwY5FGwucQJAqdaS2zKhR1AiIoBIWgEBSCQlAICkEhKASFi1DIokobDV/Y2ePjvG7D4eaA+gcVRnyi9zdj6p/Pg8vncOedqCX+amXxOYA85exle8Xg4XDDYrxQX2g9iyBMYM8uLqEXiHVKyZbbkfFt5GwLCZ9ZhbANIJwrfp3GnU/04xsidpM3X9yb8BcoYJQzEwjvg09M++3ZNyNIbP6bMa1YCjVIchK2IvBFT8PaDaig85bDbmHyHljhaZ7+eDyFS9RXo9jx9K3hMrY57tcPh6SX/fiWPO4vKZ8TeKdg6SRTx4g8qhnRl/p4/oWJIiKpQx7YUpVIJGCrfgqG7CIb9zjSaeNgG7kzhaZyx7JM07Ljy4XWnuXlEtv1P7B9Mv8DltyUV+hIpoIAAAAASUVORK5CYII=" var mimeTypes = require('mimetypes'); var image = newImageData, mimeType = image.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/)![1], fileName = 'test.' + mimeTypes.detectExtension(mimeType), base64EncodedImageString = image.replace(/^data:image\/\w+;base64,/, ''), imageBuffer = new Buffer(base64EncodedImageString, 'base64'); // Instantiate the GCP Storage instance const { Storage } = require('@google-cloud/storage'); const googleCloudStorage = new Storage(firebaseSettings); const bucket = googleCloudStorage.bucket('projectID.appspot.com'); var file = bucket.file(fileName); return file.save(imageBuffer, { metadata: { contentType: mimeType, cacheControl: "public, max-age=300" }, public: true, validation: 'md5' }, function (error: any) { if (error) { throw 'error'; } return "https://storage.googleapis.com/share-expanses-dcc9f.appspot.com/" + fileName; }); }</code></pre> </div> </div> <p>Thanks for the help</p> <br /><h3>回答1:</h3><br /><p>Haven't been able to test the solution given by Firebase, but here's the transcript of the response:</p> <blockquote> <p>The problem that you are facing could be because of two reasons. The first one is how you are uploading the files, via the Firebase Console, using any Admin SDK, or via the gsutil command. If using the Admin SDK option, the problem is a known issue where the required metadata doesn’t exist, fortunately there is a workaround, you can try this script to solve this issue. </p> <p>Now, the second one is related to the network if you are using comcast, please, try on a different network to see if this issue is related to that.</p> </blockquote> <br /><br /><br /><h3>回答2:</h3><br /><p>In my case I added metadata while uploading and it loading as it showed in image but when I'm refresh page after 3 min I found that it upload correctly , so as <strong>Cafn</strong> explain if it not matter of metadata you should wait until it loaded</p> <pre><code> $uploadedObject=$bucket-&gt;upload($imageFile, [ 'name' =&gt; 'Image_Name', "metadata" =&gt; [ "contentType"=&gt; 'image/png'], ]); </code></pre> <br /><br /><br /><h3>回答3:</h3><br /><p>When you save an image to firebase, you need to provide an access token in metadata : <code>firebaseStorageDownloadTokens</code>. It has to be an <code>uuid</code>.</p> <p>More info can be found here : https://www.sentinelstand.com/article/guide-to-firebase-storage-download-urls-tokens</p> <pre class="lang-js prettyprint-override"><code>const { v4: uuid } = require("uuid") function uploadImage() { const newImageData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAgVBMVEX///8AAAAEBASAgIDr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kyLMNNfnEbprtHAAmQCtlyL6OEq3Q34WRLcqPyb4V+RqlGVuHLMP3FEofXDPrhqsVPYIHM6xtQg86SZgZ1Kj21iWjEjVu3jL5Y3eOgEw3WK3l4vnrRVlx65qTXRFaWlGqJ/Fq1qivVUdKHMvyW3JXMJZPBs9W6BhyZ6YYZlrSW++wXHVIiaCpIg1EpO61F9syePK7fMokt8noekMWInb+rnRLzLgqu/ved3jw8tQePrq6dpp771eUDvPDA+TT25uo2Ho4v4V9n1gjvOXY6+U+P3E4OqC7K75w/DglSZymQftNyUGaxkly+ujtcOVSi7K3xF987KRXdh+jrsKn2OZK57Pl1KTkJLCaD7PejqHjcDwYsXXGyBBWs98WrBtvieWN89FkJucTkTDif9ysgTgKnDwZHMfwY5FGwucQJAqdaS2zKhR1AiIoBIWgEBSCQlAICkEhKASFi1DIokobDV/Y2ePjvG7D4eaA+gcVRnyi9zdj6p/Pg8vncOedqCX+amXxOYA85exle8Xg4XDDYrxQX2g9iyBMYM8uLqEXiHVKyZbbkfFt5GwLCZ9ZhbANIJwrfp3GnU/04xsidpM3X9yb8BcoYJQzEwjvg09M++3ZNyNIbP6bMa1YCjVIchK2IvBFT8PaDaig85bDbmHyHljhaZ7+eDyFS9RXo9jx9K3hMrY57tcPh6SX/fiWPO4vKZ8TeKdg6SRTx4g8qhnRl/p4/oWJIiKpQx7YUpVIJGCrfgqG7CIb9zjSaeNgG7kzhaZyx7JM07Ljy4XWnuXlEtv1P7B9Mv8DltyUV+hIpoIAAAAASUVORK5CYII=" var mimeTypes = require('mimetypes'); var image = newImageData, mimeType = image.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/)![1], fileName = 'test.' + mimeTypes.detectExtension(mimeType), base64EncodedImageString = image.replace(/^data:image\/\w+;base64,/, ''), imageBuffer = new Buffer(base64EncodedImageString, 'base64'); // Instantiate the GCP Storage instance const { Storage } = require('@google-cloud/storage'); const googleCloudStorage = new Storage(firebaseSettings); const bucket = googleCloudStorage.bucket('projectID.appspot.com'); var file = bucket.file(fileName); return file.save(imageBuffer, { metadata: { contentType: mimeType, cacheControl: "public, max-age=300", // THIS IS THE LINE YOU NEED TO ADD firebaseStorageDownloadTokens: uuid(), }, public: true, validation: 'md5' }, function (error: any) { if (error) { throw 'error'; } return "https://storage.googleapis.com/share-expanses-dcc9f.appspot.com/" + fileName; }); } </code></pre> <p>After that you'll need to click on "Create access token"</p> <p></p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/60480323/firebase-storage-image-preview-is-permenantly-loading</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-storage" hreflang="zh-hans">firebase-storage</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Wed, 20 Jan 2021 00:47:14 +0000 半世苍凉 4002509 at https://www.e-learn.cn Firebase Storage - Image preview is permenantly loading https://www.e-learn.cn/topic/4002508 <span>Firebase Storage - Image preview is permenantly loading</span> <span><span lang="" about="/user/139" typeof="schema:Person" property="schema:name" datatype="">删除回忆录丶</span></span> <span>2021-01-20 08:46:33</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I've started working with firebase storage and firebase functions recently. Right now I've been developing file upload from functions to storage .</p> <p>I've got it working (upload is done and file appears on the storage section), yet, the image, stays like this forever (loading forever on the right side):</p> <p></p> <p>I though that it was an error from my code. Yet, if I open Google Cloud Platform - Storage, the image appears and I can open it and preview it. </p> <p>In firebase storage, if I open the image (select on it and click open), it returns the following url: https://console.firebase.google.com/u/0/undefined</p> <p>What may I been doing wrong? Here's the code I'm using:</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>function uploadImage() { const newImageData = "data:image/png;base64,iVBORw0K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GKISOE9Ce5p6qql3//XX3XY88RNVICllvbpM7Hk+WhOab8aps0nzIeRZSoZZQYWaIkyLMNNfnEbprtHAAmQCtlyL6OEq3Q34WRLcqPyb4V+RqlGVuHLMP3FEofXDPrhqsVPYIHM6xtQg86SZgZ1Kj21iWjEjVu3jL5Y3eOgEw3WK3l4vnrRVlx65qTXRFaWlGqJ/Fq1qivVUdKHMvyW3JXMJZPBs9W6BhyZ6YYZlrSW++wXHVIiaCpIg1EpO61F9syePK7fMokt8noekMWInb+rnRLzLgqu/ved3jw8tQePrq6dpp771eUDvPDA+TT25uo2Ho4v4V9n1gjvOXY6+U+P3E4OqC7K75w/DglSZymQftNyUGaxkly+ujtcOVSi7K3xF987KRXdh+jrsKn2OZK57Pl1KTkJLCaD7PejqHjcDwYsXXGyBBWs98WrBtvieWN89FkJucTkTDif9ysgTgKnDwZHMfwY5FGwucQJAqdaS2zKhR1AiIoBIWgEBSCQlAICkEhKASFi1DIokobDV/Y2ePjvG7D4eaA+gcVRnyi9zdj6p/Pg8vncOedqCX+amXxOYA85exle8Xg4XDDYrxQX2g9iyBMYM8uLqEXiHVKyZbbkfFt5GwLCZ9ZhbANIJwrfp3GnU/04xsidpM3X9yb8BcoYJQzEwjvg09M++3ZNyNIbP6bMa1YCjVIchK2IvBFT8PaDaig85bDbmHyHljhaZ7+eDyFS9RXo9jx9K3hMrY57tcPh6SX/fiWPO4vKZ8TeKdg6SRTx4g8qhnRl/p4/oWJIiKpQx7YUpVIJGCrfgqG7CIb9zjSaeNgG7kzhaZyx7JM07Ljy4XWnuXlEtv1P7B9Mv8DltyUV+hIpoIAAAAASUVORK5CYII=" var mimeTypes = require('mimetypes'); var image = newImageData, mimeType = image.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/)![1], fileName = 'test.' + mimeTypes.detectExtension(mimeType), base64EncodedImageString = image.replace(/^data:image\/\w+;base64,/, ''), imageBuffer = new Buffer(base64EncodedImageString, 'base64'); // Instantiate the GCP Storage instance const { Storage } = require('@google-cloud/storage'); const googleCloudStorage = new Storage(firebaseSettings); const bucket = googleCloudStorage.bucket('projectID.appspot.com'); var file = bucket.file(fileName); return file.save(imageBuffer, { metadata: { contentType: mimeType, cacheControl: "public, max-age=300" }, public: true, validation: 'md5' }, function (error: any) { if (error) { throw 'error'; } return "https://storage.googleapis.com/share-expanses-dcc9f.appspot.com/" + fileName; }); }</code></pre> </div> </div> <p>Thanks for the help</p> <br /><h3>回答1:</h3><br /><p>Haven't been able to test the solution given by Firebase, but here's the transcript of the response:</p> <blockquote> <p>The problem that you are facing could be because of two reasons. The first one is how you are uploading the files, via the Firebase Console, using any Admin SDK, or via the gsutil command. If using the Admin SDK option, the problem is a known issue where the required metadata doesn’t exist, fortunately there is a workaround, you can try this script to solve this issue. </p> <p>Now, the second one is related to the network if you are using comcast, please, try on a different network to see if this issue is related to that.</p> </blockquote> <br /><br /><br /><h3>回答2:</h3><br /><p>In my case I added metadata while uploading and it loading as it showed in image but when I'm refresh page after 3 min I found that it upload correctly , so as <strong>Cafn</strong> explain if it not matter of metadata you should wait until it loaded</p> <pre><code> $uploadedObject=$bucket-&gt;upload($imageFile, [ 'name' =&gt; 'Image_Name', "metadata" =&gt; [ "contentType"=&gt; 'image/png'], ]); </code></pre> <br /><br /><br /><h3>回答3:</h3><br /><p>When you save an image to firebase, you need to provide an access token in metadata : <code>firebaseStorageDownloadTokens</code>. It has to be an <code>uuid</code>.</p> <p>More info can be found here : https://www.sentinelstand.com/article/guide-to-firebase-storage-download-urls-tokens</p> <pre class="lang-js prettyprint-override"><code>const { v4: uuid } = require("uuid") function uploadImage() { const newImageData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAgVBMVEX///8AAAAEBASAgIDr6+vw8PBYWFjU1NTGxsbz8/P29vb8/Py1tbVhYWHd3d1ra2vk5OS/v78pKSlTU1NOTk6Tk5OpqanNzc13d3dKSkplZWWbm5s5OTkfHx+NjY2Gho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3l4vnrRVlx65qTXRFaWlGqJ/Fq1qivVUdKHMvyW3JXMJZPBs9W6BhyZ6YYZlrSW++wXHVIiaCpIg1EpO61F9syePK7fMokt8noekMWInb+rnRLzLgqu/ved3jw8tQePrq6dpp771eUDvPDA+TT25uo2Ho4v4V9n1gjvOXY6+U+P3E4OqC7K75w/DglSZymQftNyUGaxkly+ujtcOVSi7K3xF987KRXdh+jrsKn2OZK57Pl1KTkJLCaD7PejqHjcDwYsXXGyBBWs98WrBtvieWN89FkJucTkTDif9ysgTgKnDwZHMfwY5FGwucQJAqdaS2zKhR1AiIoBIWgEBSCQlAICkEhKASFi1DIokobDV/Y2ePjvG7D4eaA+gcVRnyi9zdj6p/Pg8vncOedqCX+amXxOYA85exle8Xg4XDDYrxQX2g9iyBMYM8uLqEXiHVKyZbbkfFt5GwLCZ9ZhbANIJwrfp3GnU/04xsidpM3X9yb8BcoYJQzEwjvg09M++3ZNyNIbP6bMa1YCjVIchK2IvBFT8PaDaig85bDbmHyHljhaZ7+eDyFS9RXo9jx9K3hMrY57tcPh6SX/fiWPO4vKZ8TeKdg6SRTx4g8qhnRl/p4/oWJIiKpQx7YUpVIJGCrfgqG7CIb9zjSaeNgG7kzhaZyx7JM07Ljy4XWnuXlEtv1P7B9Mv8DltyUV+hIpoIAAAAASUVORK5CYII=" var mimeTypes = require('mimetypes'); var image = newImageData, mimeType = image.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/)![1], fileName = 'test.' + mimeTypes.detectExtension(mimeType), base64EncodedImageString = image.replace(/^data:image\/\w+;base64,/, ''), imageBuffer = new Buffer(base64EncodedImageString, 'base64'); // Instantiate the GCP Storage instance const { Storage } = require('@google-cloud/storage'); const googleCloudStorage = new Storage(firebaseSettings); const bucket = googleCloudStorage.bucket('projectID.appspot.com'); var file = bucket.file(fileName); return file.save(imageBuffer, { metadata: { contentType: mimeType, cacheControl: "public, max-age=300", // THIS IS THE LINE YOU NEED TO ADD firebaseStorageDownloadTokens: uuid(), }, public: true, validation: 'md5' }, function (error: any) { if (error) { throw 'error'; } return "https://storage.googleapis.com/share-expanses-dcc9f.appspot.com/" + fileName; }); } </code></pre> <p>After that you'll need to click on "Create access token"</p> <p></p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/60480323/firebase-storage-image-preview-is-permenantly-loading</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-storage" hreflang="zh-hans">firebase-storage</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Wed, 20 Jan 2021 00:46:33 +0000 删除回忆录丶 4002508 at https://www.e-learn.cn Firebase Storage - Image preview is permenantly loading https://www.e-learn.cn/topic/4002507 <span>Firebase Storage - Image preview is permenantly loading</span> <span><span lang="" about="/user/217" typeof="schema:Person" property="schema:name" datatype="">随声附和</span></span> <span>2021-01-20 08:46:25</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I've started working with firebase storage and firebase functions recently. Right now I've been developing file upload from functions to storage .</p> <p>I've got it working (upload is done and file appears on the storage section), yet, the image, stays like this forever (loading forever on the right side):</p> <p></p> <p>I though that it was an error from my code. Yet, if I open Google Cloud Platform - Storage, the image appears and I can open it and preview it. </p> <p>In firebase storage, if I open the image (select on it and click open), it returns the following url: https://console.firebase.google.com/u/0/undefined</p> <p>What may I been doing wrong? Here's the code I'm using:</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>function uploadImage() { const newImageData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAgVBMVEX///8AAAAEBASAgIDr6+vw8PBYWFjU1NTGxsbz8/P29vb8/Py1tbVhYWHd3d1ra2vk5O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MP3FEofXDPrhqsVPYIHM6xtQg86SZgZ1Kj21iWjEjVu3jL5Y3eOgEw3WK3l4vnrRVlx65qTXRFaWlGqJ/Fq1qivVUdKHMvyW3JXMJZPBs9W6BhyZ6YYZlrSW++wXHVIiaCpIg1EpO61F9syePK7fMokt8noekMWInb+rnRLzLgqu/ved3jw8tQePrq6dpp771eUDvPDA+TT25uo2Ho4v4V9n1gjvOXY6+U+P3E4OqC7K75w/DglSZymQftNyUGaxkly+ujtcOVSi7K3xF987KRXdh+jrsKn2OZK57Pl1KTkJLCaD7PejqHjcDwYsXXGyBBWs98WrBtvieWN89FkJucTkTDif9ysgTgKnDwZHMfwY5FGwucQJAqdaS2zKhR1AiIoBIWgEBSCQlAICkEhKASFi1DIokobDV/Y2ePjvG7D4eaA+gcVRnyi9zdj6p/Pg8vncOedqCX+amXxOYA85exle8Xg4XDDYrxQX2g9iyBMYM8uLqEXiHVKyZbbkfFt5GwLCZ9ZhbANIJwrfp3GnU/04xsidpM3X9yb8BcoYJQzEwjvg09M++3ZNyNIbP6bMa1YCjVIchK2IvBFT8PaDaig85bDbmHyHljhaZ7+eDyFS9RXo9jx9K3hMrY57tcPh6SX/fiWPO4vKZ8TeKdg6SRTx4g8qhnRl/p4/oWJIiKpQx7YUpVIJGCrfgqG7CIb9zjSaeNgG7kzhaZyx7JM07Ljy4XWnuXlEtv1P7B9Mv8DltyUV+hIpoIAAAAASUVORK5CYII=" var mimeTypes = require('mimetypes'); var image = newImageData, mimeType = image.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/)![1], fileName = 'test.' + mimeTypes.detectExtension(mimeType), base64EncodedImageString = image.replace(/^data:image\/\w+;base64,/, ''), imageBuffer = new Buffer(base64EncodedImageString, 'base64'); // Instantiate the GCP Storage instance const { Storage } = require('@google-cloud/storage'); const googleCloudStorage = new Storage(firebaseSettings); const bucket = googleCloudStorage.bucket('projectID.appspot.com'); var file = bucket.file(fileName); return file.save(imageBuffer, { metadata: { contentType: mimeType, cacheControl: "public, max-age=300" }, public: true, validation: 'md5' }, function (error: any) { if (error) { throw 'error'; } return "https://storage.googleapis.com/share-expanses-dcc9f.appspot.com/" + fileName; }); }</code></pre> </div> </div> <p>Thanks for the help</p> <br /><h3>回答1:</h3><br /><p>Haven't been able to test the solution given by Firebase, but here's the transcript of the response:</p> <blockquote> <p>The problem that you are facing could be because of two reasons. The first one is how you are uploading the files, via the Firebase Console, using any Admin SDK, or via the gsutil command. If using the Admin SDK option, the problem is a known issue where the required metadata doesn’t exist, fortunately there is a workaround, you can try this script to solve this issue. </p> <p>Now, the second one is related to the network if you are using comcast, please, try on a different network to see if this issue is related to that.</p> </blockquote> <br /><br /><br /><h3>回答2:</h3><br /><p>In my case I added metadata while uploading and it loading as it showed in image but when I'm refresh page after 3 min I found that it upload correctly , so as <strong>Cafn</strong> explain if it not matter of metadata you should wait until it loaded</p> <pre><code> $uploadedObject=$bucket-&gt;upload($imageFile, [ 'name' =&gt; 'Image_Name', "metadata" =&gt; [ "contentType"=&gt; 'image/png'], ]); </code></pre> <br /><br /><br /><h3>回答3:</h3><br /><p>When you save an image to firebase, you need to provide an access token in metadata : <code>firebaseStorageDownloadTokens</code>. It has to be an <code>uuid</code>.</p> <p>More info can be found here : https://www.sentinelstand.com/article/guide-to-firebase-storage-download-urls-tokens</p> <pre class="lang-js prettyprint-override"><code>const { v4: uuid } = require("uuid") function uploadImage() { const newImageData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAgVBMVEX///8AAAAEBASAgIDr6+vw8PBYWFjU1NTGxsbz8/P29vb8/Py1tbVhYWHd3d1ra2vk5OS/v78pKSlTU1NOTk6Tk5OpqanNzc13d3dKSkplZWWbm5s5OTkfHx+NjY2GhoYcHBw9PT0TExOioqJ7e3soKCiurq5CQkI6OjoXFxcwMDAuPQWoAAAIJ0lEQVR4nO2daXuqPBCGVfYtIbKLgorLKf//B75ga2sPAdmS8F5n7m/VXgyP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/ved3jw8tQePrq6dpp771eUDvPDA+TT25uo2Ho4v4V9n1gjvOXY6+U+P3E4OqC7K75w/DglSZymQftNyUGaxkly+ujtcOVSi7K3xF987KRXdh+jrsKn2OZK57Pl1KTkJLCaD7PejqHjcDwYsXXGyBBWs98WrBtvieWN89FkJucTkTDif9ysgTgKnDwZHMfwY5FGwucQJAqdaS2zKhR1AiIoBIWgEBSCQlAICkEhKASFi1DIokobDV/Y2ePjvG7D4eaA+gcVRnyi9zdj6p/Pg8vncOedqCX+amXxOYA85exle8Xg4XDDYrxQX2g9iyBMYM8uLqEXiHVKyZbbkfFt5GwLCZ9ZhbANIJwrfp3GnU/04xsidpM3X9yb8BcoYJQzEwjvg09M++3ZNyNIbP6bMa1YCjVIchK2IvBFT8PaDaig85bDbmHyHljhaZ7+eDyFS9RXo9jx9K3hMrY57tcPh6SX/fiWPO4vKZ8TeKdg6SRTx4g8qhnRl/p4/oWJIiKpQx7YUpVIJGCrfgqG7CIb9zjSaeNgG7kzhaZyx7JM07Ljy4XWnuXlEtv1P7B9Mv8DltyUV+hIpoIAAAAASUVORK5CYII=" var mimeTypes = require('mimetypes'); var image = newImageData, mimeType = image.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/)![1], fileName = 'test.' + mimeTypes.detectExtension(mimeType), base64EncodedImageString = image.replace(/^data:image\/\w+;base64,/, ''), imageBuffer = new Buffer(base64EncodedImageString, 'base64'); // Instantiate the GCP Storage instance const { Storage } = require('@google-cloud/storage'); const googleCloudStorage = new Storage(firebaseSettings); const bucket = googleCloudStorage.bucket('projectID.appspot.com'); var file = bucket.file(fileName); return file.save(imageBuffer, { metadata: { contentType: mimeType, cacheControl: "public, max-age=300", // THIS IS THE LINE YOU NEED TO ADD firebaseStorageDownloadTokens: uuid(), }, public: true, validation: 'md5' }, function (error: any) { if (error) { throw 'error'; } return "https://storage.googleapis.com/share-expanses-dcc9f.appspot.com/" + fileName; }); } </code></pre> <p>After that you'll need to click on "Create access token"</p> <p></p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/60480323/firebase-storage-image-preview-is-permenantly-loading</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-storage" hreflang="zh-hans">firebase-storage</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Wed, 20 Jan 2021 00:46:25 +0000 随声附和 4002507 at https://www.e-learn.cn What benefit does linking Firebase web app to Firebase Hosting site brings? https://www.e-learn.cn/topic/3920937 <span>What benefit does linking Firebase web app to Firebase Hosting site brings?</span> <span><span lang="" about="/user/128" typeof="schema:Person" property="schema:name" datatype="">别等时光非礼了梦想.</span></span> <span>2020-11-18 02:51:27</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>来源:<code>https://stackoverflow.com/questions/64409754/what-benefit-does-linking-firebase-web-app-to-firebase-hosting-site-brings</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-hosting" hreflang="zh-hans">firebase-hosting</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Tue, 17 Nov 2020 18:51:27 +0000 别等时光非礼了梦想. 3920937 at https://www.e-learn.cn What benefit does linking Firebase web app to Firebase Hosting site brings? https://www.e-learn.cn/topic/3920917 <span>What benefit does linking Firebase web app to Firebase Hosting site brings?</span> <span><span lang="" about="/user/164" typeof="schema:Person" property="schema:name" datatype="">烈酒焚心</span></span> <span>2020-11-18 02:50:30</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>来源:<code>https://stackoverflow.com/questions/64409754/what-benefit-does-linking-firebase-web-app-to-firebase-hosting-site-brings</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-hosting" hreflang="zh-hans">firebase-hosting</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Tue, 17 Nov 2020 18:50:30 +0000 烈酒焚心 3920917 at https://www.e-learn.cn Firebase Storage View by certain users https://www.e-learn.cn/topic/3881562 <span>Firebase Storage View by certain users</span> <span><span lang="" about="/user/216" typeof="schema:Person" property="schema:name" datatype="">假如想象</span></span> <span>2020-10-26 18:34:38</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>来源:<code>https://stackoverflow.com/questions/61986342/firebase-storage-view-by-certain-users</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/firebase" hreflang="zh-hans">firebase</a></div> <div class="field--item"><a href="/tag/firebase-realtime-database" hreflang="zh-hans">firebase-realtime-database</a></div> <div class="field--item"><a href="/tag/firebase-storage" hreflang="zh-hans">firebase-storage</a></div> <div class="field--item"><a href="/tag/firebase-console" hreflang="zh-hans">firebase-console</a></div> </div> </div> Mon, 26 Oct 2020 10:34:38 +0000 假如想象 3881562 at https://www.e-learn.cn