title | summary | toc |
---|---|---|
cockroach userfile list |
List the files stored in the user-scoped file storage. |
true |
New in v20.2: The cockroach userfile list
command lists the files 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 listed.
The user must have the CREATE
privilege 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 view files in their own user-scoped storage, which is accessed through the userfile URI used during the upload. CockroachDB will revoke all access from every other user in the cluster except users in the admin
role.
View files:
$ cockroach userfile list <file | dir> [flags]
View help:
$ cockroach userfile list --help
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 containing the CA and client certificates and client key.
Env Variable: COCKROACH_CERTS_DIR
Default: ${HOME}/.cockroach-certs/
--echo-sql
| Reveal the SQL statements sent implicitly by the command-line utility.
--url
| A connection URL to use instead of the other arguments.
Env Variable: COCKROACH_URL
Default: no URL
--user
-u
| The SQL user that will own the client session.
Env Variable: COCKROACH_USER
Default: root
If the file or directory is not specified, all files in the default user-scoped storage (userfile://defaultdb.public.userfiles_$user/
) will be listed:
{% include copy-clipboard.html %}
$ cockroach userfile list --certs-dir=certs
userfile://defaultdb.public.userfiles_root/test-data-2.csv
userfile://defaultdb.public.userfiles_root/test-data.csv
userfile://defaultdb.public.userfiles_root/test-upload/test-data.csv
To list all files in a specified directory:
{% include copy-clipboard.html %}
$ cockroach userfile list test-data.csv --certs-dir=certs
userfile://defaultdb.public.userfiles_root/test-data.csv
To list all files that match a pattern, use *
:
{% include copy-clipboard.html %}
$ cockroach userfile list '*.csv' --certs-dir=certs
userfile://defaultdb.public.userfiles_root/test-data-2.csv
userfile://defaultdb.public.userfiles_root/test-data.csv
If you uploaded a file to a non-default userfile URI (e.g., userfile://testdb.public.uploads
):
{% include copy-clipboard.html %}
cockroach userfile upload /Users/maxroach/Desktop/test-data.csv userfile://testdb.public.uploads/test-data.csv
Use the same URI to view it:
{% include copy-clipboard.html %}
cockroach userfile list userfile://testdb.public.uploads