Skip to content

Commit

Permalink
inital commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gemma-shay committed Mar 8, 2021
1 parent ef412f9 commit fb2c600
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions v21.1/cockroach-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Command | Usage
[`cockroach userfile upload`](cockroach-userfile-upload.html) | Upload a file to the user-scoped file storage.
[`cockroach userfile list`](cockroach-userfile-list.html) | List the files stored in the user-scoped file storage.
[`cockroach userfile delete`](cockroach-userfile-delete.html) | Deletes the files stored in the user-scoped file storage.
[`cockroach userfile get`](cockroach-userfile-get.html) | Fetch a file from the user-scoped file storage.
[`cockroach import`](cockroach-import.html) | <span class="version-tag">New in v21.1:</span> Import a table or database from a local dump file into a running cluster. `PGDUMP` and `MYSQLDUMP` file formats are currently supported.

## Environment variables
Expand Down
1 change: 1 addition & 0 deletions v21.1/cockroach-userfile-delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ cockroach userfile delete userfile://testdb.public.uploads

- [`cockroach userfile upload`](cockroach-userfile-upload.html)
- [`cockroach userfile list`](cockroach-userfile-list.html)
- [`cockroach userfile get`](cockroach-userfile-get.html)
- [Use `userfile` for Bulk Operations](use-userfile-for-bulk-operations.html)
- [Other Cockroach Commands](cockroach-commands.html)
- [`IMPORT`](import.html)
Expand Down
83 changes: 83 additions & 0 deletions v21.1/cockroach-userfile-get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: cockroach userfile get
summary: Fetch files stored in the user-scoped file storage.
toc: true
---

<span class="version-tag">New in v21.1:</span> The `cockroach userfile get` command fetches a file stored in the user-scoped file storage which match the provided pattern, using a SQL connection. If no pattern is provided, all files in the specified (or default, if unspecified) user scoped file storage will be fetched.

## Required privileges

The user must have the `CREATE` [privilege](authorization.html#assign-privileges) on the target database. CockroachDB will proactively grant the user `GRANT`, `SELECT`, `INSERT`, `DROP`, `DELETE` on the metadata and file tables.

A user can only fetch files from their own user-scoped storage, which is accessed through the [userfile URI](cockroach-userfile-upload.html#file-destination) used during the upload. CockroachDB will revoke all access from every other user in the cluster except users in the `admin` role and users explicitly granted access.

## Synopsis

Fetch a file:

~~~ shell
$ cockroach userfile get <file> [flags]
~~~

View help:

~~~ shell
$ cockroach userfile get --help
~~~

## Flags

Flag | Description
-----------------+-----------------------------------------------------
`--cert-principal-map` | A comma-separated list of `<cert-principal>:<db-principal>` mappings. This allows mapping the principal in a cert to a DB principal such as `node` or `root` or any SQL user. This is intended for use in situations where the certificate management system places restrictions on the `Subject.CommonName` or `SubjectAlternateName` fields in the certificate (e.g., disallowing a `CommonName` like `node` or `root`). If multiple mappings are provided for the same `<cert-principal>`, the last one specified in the list takes precedence. A principal not specified in the map is passed through as-is via the identity function. A cert is allowed to authenticate a DB principal if the DB principal name is contained in the mapped `CommonName` or DNS-type `SubjectAlternateName` fields.
`--certs-dir` | The path to the [certificate directory](cockroach-cert.html) containing the CA and client certificates and client key.<br><br>**Env Variable:** `COCKROACH_CERTS_DIR`<br>**Default:** `${HOME}/.cockroach-certs/`
`--echo-sql` | Reveal the SQL statements sent implicitly by the command-line utility.
`--url` | A [connection URL](connection-parameters.html#connect-using-a-url) to use instead of the other arguments.<br><br>**Env Variable:** `COCKROACH_URL`<br>**Default:** no URL
`--user`<br>`-u` | The [SQL user](create-user.html) that will own the client session.<br><br>**Env Variable:** `COCKROACH_USER`<br>**Default:** `root`

## Examples

### Get a specific file

To get the file named test-data.csv from the default user-scoped storage location for the current user:

{% include copy-clipboard.html %}
~~~ shell
$ cockroach userfile get test-data.csv --certs-dir=certs
~~~

### Get a file saved to an explicit local file name

To get a file named test-data.csv from a local directory:

{% include copy-clipboard.html %}
~~~ shell
$ cockroach userfile get test-data.csv /Users/maxroach/Desktop/test-data.csv --certs-dir=certs
~~~

### Get a file from a non-default userfile URI

If you [uploaded a file to a non-default userfile URI](cockroach-userfile-upload.html#upload-a-file-to-a-non-default-userfile-uri) (e.g., `userfile://testdb.public.uploads`), use the same URI to fetch it:

{% include copy-clipboard.html %}
~~~ shell
cockroach userfile get userfile://testdb.public.uploads/test-data.csv --certs-dir=certs
~~~

### Get files that match the provided pattern

To get all files that match a pattern, use *:

{% include copy-clipboard.html %}
~~~ shell
$ cockroach userfile get '*.csv' --certs-dir=certs
~~~

## See also

- [`cockroach userfile upload`](cockroach-userfile-upload.html)
- [`cockroach userfile delete`](cockroach-userfile-delete.html)
- [`cockroach userfile list`](cockroach-userfile-list.html)
- [Use `userfile` for Bulk Operations](use-userfile-for-bulk-operations.html)
- [Other Cockroach Commands](cockroach-commands.html)
1 change: 1 addition & 0 deletions v21.1/cockroach-userfile-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ cockroach userfile list userfile://testdb.public.uploads

- [`cockroach userfile upload`](cockroach-userfile-upload.html)
- [`cockroach userfile delete`](cockroach-userfile-delete.html)
- [`cockroach userfile get`](cockroach-userfile-get.html)
- [Use `userfile` for Bulk Operations](use-userfile-for-bulk-operations.html)
- [Other Cockroach Commands](cockroach-commands.html)
- [`IMPORT`](import.html)
Expand Down
1 change: 1 addition & 0 deletions v21.1/cockroach-userfile-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ successfully uploaded to userfile://testdb.public.uploads/test-data.csv

- [`cockroach userfile list`](cockroach-userfile-list.html)
- [`cockroach userfile delete`](cockroach-userfile-delete.html)
- [`cockroach userfile get`](cockroach-userfile-get.html)
- [Use `userfile` for Bulk Operations](use-userfile-for-bulk-operations.html)
- [Other Cockroach Commands](cockroach-commands.html)
- [`IMPORT`](import.html)
Expand Down

0 comments on commit fb2c600

Please sign in to comment.