Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): Firebase Storage docs #902

Merged
merged 11 commits into from Jan 23, 2017
Merged

feat(docs): Firebase Storage docs #902

merged 11 commits into from Jan 23, 2017

Conversation

davideast
Copy link
Contributor

Documentation for the $firebaseStorage() service and firebase-src directive.

@coveralls
Copy link

coveralls commented Jan 17, 2017

Coverage Status

Coverage remained the same at 93.716% when pulling d4fc74f on storage-docs into 94ca5bc on master.

Copy link

@jwngr jwngr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to go run to a meeting, but I'm about two third of the way done and figured I'd send you what I have so far. Overall, the content looks good. Mainly just have minor suggestions around styling and formatting.


* [Overview](#overview)
* [API Summary](#api-summary)
* [Uploading files](#uploading-files)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other guide pages use all-caps for the section titles. Please update these to make them consistent.

## Overview

Firebase provides [a hosted binary storage service](https://firebase.google.com/docs/storage/)
which enables you to store and retrieve user-generated content like images, audio and
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: add Oxford comma after audio since we use it elsewhere.

video directly from the Firebase client SDK.

Binary files are stored in a Firebase Storage bucket, not in the Realtime Database.
The file files in your bucket are stored in a hierarchical structure, just like
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/file files/files

in the Realtime Database.

To use the Firebase Storage binding, first [create a Firebase Storage reference](https://firebase.google.com/docs/storage/web/create-reference).
Then using this reference, pass it into the `$firebaseStorage` service.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Then using/Then, using

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, replace the closing period with a colon.

// inject $firebaseStorage into our controller
function SampleCtrl($firebaseStorage) {
// create a Firebase Storage Reference for the $firebaseStorage binding
var storageRef = firebase.storage().ref('userProfiles/physicsmarie');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use double quotes.

var storageRef = firebase.storage().ref('userProfiles/physicsmarie');
var storage = $firebaseStorage(storageRef);
}
SampleCtrl.$inject = ["$firebaseStorage"];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need this line? Also, can we make this style consistent with how we define the module and controller elsewhere in the docs (e.g. here)?


| Method | Description |
| ------------- | ------------- |
| [`$progress(callback)`](/docs/reference.md#uploadtask-progress) | Calls the provided callback function whenever there is an update in the progress of the file uploading. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links for all of these methods are broken. It looks like they don't need a leading "uploadtask-".

| Method | Description |
| ------------- | ------------- |
| [`$progress(callback)`](/docs/reference.md#uploadtask-progress) | Calls the provided callback function whenever there is an update in the progress of the file uploading. |
| [`$error(callback)`](/docs/reference.md#uploadtask-error) | Calls the provided callback function when there is an error uploading the file |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add period to end of description.

| [`$cancel()`](/docs/reference.md#uploadtask-cancel) | Cancels the upload. |
| [`$pause()`](/docs/reference.md#uploadtask-pause) | Pauses the upload. |
| [`$snapshot()`](/docs/reference.md#uploadtask-$snapshot) | Returns the [current immutable view of the task](https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_progress) at the time the event occurred. |
| [`then(callback)`](/docs/reference.md#uploadtask-then) | An Upload Task implements a promise like interface. The callback is called when the upload is complete. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Upload Task/UploadTask (and add backticks around it)
s/promise/Promise (and add backticks around it)
s/The callback/This callback

| [`$pause()`](/docs/reference.md#uploadtask-pause) | Pauses the upload. |
| [`$snapshot()`](/docs/reference.md#uploadtask-$snapshot) | Returns the [current immutable view of the task](https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_progress) at the time the event occurred. |
| [`then(callback)`](/docs/reference.md#uploadtask-then) | An Upload Task implements a promise like interface. The callback is called when the upload is complete. |
| [`catch(callback)`](/docs/reference.md#uploadtask-then) | An Upload Task implements a promise like interface. The callback is called when an error occurs. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on the comment above.

Copy link

@jwngr jwngr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, all done with my first pass.

| [`catch(callback)`](/docs/reference.md#uploadtask-then) | An Upload Task implements a promise like interface. The callback is called when an error occurs. |

## Displaying images with the `firebase-src` directive
AngularFire provides a directive that displays a file with any `src` compatible element.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new line after the header.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: src-compatible

## Displaying images with the `firebase-src` directive
AngularFire provides a directive that displays a file with any `src` compatible element.

Instead of using the tradional `src` attribute, use `firebase-src`:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just make this part of the previous paragraph?

```

## Retrieving files from the template
AngularFire does not provide a directive for retrieving a upload file. However,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new line after header.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/a upload/an uploaded


## Retrieving files from the template
AngularFire does not provide a directive for retrieving a upload file. However,
the below directive is basic but provides a baseline to work off.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: get rid of "is basic but" and replace the closing period with a colon.

scope: {
onChange: "="
},
template: "<input type="file" name="file" class="inputfile" /><label><ng-transclude></ng-transclude></label>",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity, I would suggest dropping the class attribute as it isn't really required for this example to work.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within the template, you should use single quotes or escape the double quotes.

var asString = $scope.storage.$toString();
```

## Upload Task
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have three # characters.

var uploadTask = $scope.storage.$put(htmlFile, { contentType: 'text/html' });
```

## $putString(string, format, metadata)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All methods directly off of $firebaseStorage should have three # characters, not two.

var uploadTask = $scope.storage.$put(htmlFile, { contentType: 'text/html' });
```

## $progress(callback)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All headers under Upload Task should have four # characters, not two.

$scope.bytesTransferred = uploadTask.$snapshot.bytesTransferred;
```

## Upload Task then()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be then()?

});
```

## Upload Task catch()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be catch()?

@CyrusZei
Copy link

Oh this is perfect, You guys are soon done with it and I just cant wait! Keep up the good work guys, you are the best

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.716% when pulling 7c990e7 on storage-docs into 94ca5bc on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.716% when pulling 8b5244b on storage-docs into 94ca5bc on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.716% when pulling 5cfa40e on storage-docs into 94ca5bc on master.

@coveralls
Copy link

coveralls commented Jan 18, 2017

Coverage Status

Coverage remained the same at 93.716% when pulling b34edba on storage-docs into 94ca5bc on master.

Copy link

@jwngr jwngr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are good after a few last edits.

| [`then(callback)`](/docs/reference.md#then) | An `UploadTask` implements a `Promise` like interface. This callback is called when the upload is complete. |
| [`catch(callback)`](/docs/reference.md#catch) | An `UploadTask` implements a `Promise` like interface. This callback is called when an error occurs. |

## Displaying images with the `firebase-src` directive
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be title-case.

<img firebase-src="{{ userProfileId }}" />
```

## Retrieving files from the template
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be title-case.

@@ -0,0 +1,147 @@
# Uploading & Downloading Binary Content | AngularFire Guide
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A link to this page needs to get added to https://github.com/firebase/angularfire/blob/master/docs/guide/README.md. I think putting it as #4 (in between the Database and Auth sections) makes the most sense. Also, we need to make sure to update the link at the end of guide section #3 now links to this guide and, at the end of this guide, link to guide section #5 (which will now be the Auth section).


| Method | Description |
| ------------- | ------------- |
| [`$put(file, metadata)`](/docs/reference.md#putfile-metadata) | Uploads file to configured path with optional metadata. Returns an AngularFire wrapped `UploadTask`. |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's link UploadTask to #upload-task-api-summary everywhere in this API summary (four instances).


## Retrieving files from the template

AngularFire does not provide a directive for retrieving an upload file. However,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/upload/uploaded

Returns a promise fulfilled with the updated metadata.

```js
var updateData = { contenType: 'text/plain' };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use double quotes.


```js
var updateData = { contenType: 'text/plain' };
$scope.storage.$updateMetadata(updateData).then(function(completeMetadata) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/completeMetadata/updatedMetadata


```js
$scope.storage.$delete().then(function() {
console.log('successfully deleted!');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use double quotes.

### Upload Task

The [`$firebaseStorage()`](#firebasestorage) service returns an AngularFire wrapped [`UploadTask`](https://firebase.google.com/docs/reference/js/firebase.storage#uploadtask) when uploading binary content
using the [`$put()`]($putfile-metadata) and [`$putString()`](#putstringstring-format-metadata) methods. This task is used for [monitoring](https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_progress)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link for $put() 404s.

and [managing](https://firebase.google.com/docs/storage/web/upload-files#manage_uploads) uploads.

```js
var htmlFile = new Blob(["<html></html>"], {type : "text/html"});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on comment above regarding padding spaces.

@jwngr jwngr assigned davideast and unassigned jwngr Jan 19, 2017
@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.716% when pulling 82c3cf1 on storage-docs into 94ca5bc on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.716% when pulling 73f2e77 on storage-docs into 94ca5bc on master.

@davideast davideast merged commit fe25154 into master Jan 23, 2017
@davideast davideast deleted the storage-docs branch January 23, 2017 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants