R6 Class representing a resource for managing files and folders.
Super class
sevenbridges2::Item
-> File
Public fields
URL
List of URL endpoints for this resource.
id
File ID.
name
File name.
size
File size.
project
Project ID if any, where file/folder is located.
created_on
Date file/folder was created on.
modified_on
Date file/folder was modified on.
storage
File/folder's storage type.
origin
Task ID if file/folder is produced by some task execution.
tags
List of tags associated with the file.
metadata
List for metadata associated with the file.
url
File download URL.
parent
Parent folder ID.
type
This can be of type
file
orfolder
.secondary_files
Secondary files linked to the file if exist.
Methods
Method print()
Print method for File class.
Method detailed_print()
Detailed print method for File class.
Details
The call returns the file's name, its tags, and all of its metadata. Apart from regular file fields there are some additional fields:
storage
field denotes the type of storage for the file which can be either PLATFORM or VOLUME depending on where the file is stored.origin
field denotes the task that produced the file, if it was created by a task on the Seven Bridges Platform.metadata
field lists the metadata fields and values for the file.tags
field lists the tags for the file. Learn more about tagging your files on the Platform.
Method reload()
Reload File object information.
Arguments
...
Other arguments that can be passed to core
api()
function like 'fields', etc.
Method update()
Updates the name, the full set metadata, and tags for a specified file. .
Arguments
name
The new name of the file.
metadata
The metadata fields and their values that you want to update. This is a named list of key-value pairs. The keys and values are strings.
tags
The tags you want to update, represented as unnamed list of values to add as tags.
...
Other arguments that can be passed to core
api()
function like 'limit', 'offset', 'fields', etc.
Method add_tag()
This method allows you to tag files on the Platform.
You can tag your files on the Platform with keywords to make it easier
to identify and organize files you’ve imported from public datasets
or copied between projects.
More details on how to use this call can be found
here.
Method copy_to()
This call copies the specified file to a new project.
Files retain their metadata when copied, but may be assigned new names
in their target project. To make this call, you should have
copy permission
within the project you are copying from.
Note: If you want to copy
multiple files, the recommended way is to do it in bulk considering the
API rate limit
(learn more).
You can do that using Auth$copy_files()
operation.
Arguments
project
The ID of the project or a Project object where you want to copy the file to.
name
The new name the file will have in the target project. If its name will not change, omit this key.
...
Other arguments that can be passed to core
api()
function like 'fields', etc.
Method get_download_url()
This method returns a URL that you can use to download the specified file.
Arguments
...
Other arguments that can be passed to core
api()
function like 'fields', etc.
Method get_metadata()
This call returns the metadata values for the specified file.
Arguments
...
Other arguments that can be passed to core
api()
function like 'fields', etc.
Method set_metadata()
This call changes the metadata values for the specified
file.
More details about how to modify metadata, you can find in the
API documentation.
Arguments
metadata_fields
Enter a list of key-value pairs of metadata fields and metadata values.
overwrite
Set to
TRUE
if you want to overwrite existing tags. Default:FALSE
....
Other arguments that can be passed to core
api()
function like 'fields', etc.
Method move_to_folder()
This call moves a file from one folder to another. Moving of files is only allowed within the same project.
Method list_contents()
List folder contents.
Arguments
limit
The maximum number of collection items to return for a single request. Minimum value is
1
. The maximum value is100
and the default value is50
. This is a pagination-specific attribute.offset
The zero-based starting index in the entire collection of the first item to return. The default value is
0
. This is a pagination-specific attribute....
Other arguments that can be passed to core
api()
function like 'fields', etc.
Returns
Collection
of File
objects.
Method download()
Download method for File objects. It allows download a
platform file to your local computer. To specify the destination for
your download, you should provide the path to the destination directory
as directory_path
parameter.
Arguments
directory_path
Path to the destination directory of a new file.
filename
Full name for the new file, including its extension. By default, the name field of File object will be used.
method
Method to be used for downloading files. By default, this parameter is set to
curl
.retry_count
Number of retries if error occurs during download.
retry_timeout
Number of seconds between two retries.
Method submit_export()
This call lets you queue a job to export this file from a
project on the Platform into a volume. The file selected for export must
not be a public file or an alias. Aliases are objects stored in your
cloud storage bucket which have been made available on the Platform.
The volume you are exporting to must be configured for read-write
access. To do this, set the access_mode
parameter to RW
when
creating or modifying a volume.
Essentially, the call writes to your cloud storage bucket via the
volume. If this call is successful, the original project file will
become an alias to the newly exported object on the volume. The source
file will be deleted from the Platform and, if no more copies of this
file exist, it will no longer count towards your total storage price
on the Platform.
In summary, once you export a file from the Platform to a volume,
it is no longer part of the storage on the Platform and
cannot be exported again.
Read more about this operation in our documentation
here.
If you want to export multiple files, the recommended way is to do it
in bulk considering the API rate limit
(learn more)
(bulk operations will be implemented in next releases).
Usage
File$submit_export(
destination_volume,
destination_location,
overwrite = FALSE,
copy_only = FALSE,
properties = NULL,
...
)
Arguments
destination_volume
Volume id or Volume object you want to export files into. Required.
destination_location
Volume-specific location to which the file will be exported. This location should be recognizable to the underlying cloud service as a valid key or path to a new file. Please note that if this volume has been configured with a prefix parameter, the value of prefix will be prepended to location before attempting to create the file on the volume.
If you would like to export the file into some folder on the volume, please add folder name as prefix before file name in form
<folder-name>/<file-name>
.overwrite
Set to
TRUE
of you want to overwrite the item that already exists at the destination. Default:FALSE
.copy_only
If
TRUE
, file will be copied to a volume but source file will remain on the Platform.properties
Named list of additional volume properties, like:
sse_algorithm
- S3 server-side encryption to use when exporting to this bucket. Supported values:AES256
(SSE-S3 encryption),aws:kms
,null
(no server-side encryption). Default:AES256
.sse_aws_kms_key_id
: Applies to type:s3
. If AWS KMS encryption is used, this should be set to the required KMS key. If not set andaws:kms
is set assse_algorithm
, default KMS key is used.aws_canned_acl
: S3 canned ACL to apply on the object on during export. Supported values: any one of S3 canned ACLs;null
(do not apply canned ACLs). Default:null
.
...
Other arguments that can be passed to core
api()
function like 'fields', etc.
Returns
Export
object.
Examples
## ------------------------------------------------
## Method `File$print`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Print file object
file_object$print()
}
## ------------------------------------------------
## Method `File$detailed_print`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Detailed print of file object
file_object$detailed_print()
}
## ------------------------------------------------
## Method `File$reload`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Reload file object
file_object$reload()
}
## ------------------------------------------------
## Method `File$update`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Update file object
file_object$update(name = "new_name")
}
## ------------------------------------------------
## Method `File$add_tag`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Add new tag to file object
file_object$add_tag(tags = c("new_tag"))
}
## ------------------------------------------------
## Method `File$copy_to`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Copy file object to project
file_object$copy_to(project = project)
}
## ------------------------------------------------
## Method `File$get_download_url`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Get download url for file object
file_object$get_download_url()
}
## ------------------------------------------------
## Method `File$get_metadata`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Get metadata for file object
file_object$get_metadata()
}
## ------------------------------------------------
## Method `File$set_metadata`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Set metadata for file object
file_object$set_metadata(metadata_fields = list("field_1" = "value_1"))
}
## ------------------------------------------------
## Method `File$move_to_folder`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Move file object to a project
file_object$move_to_folder(parent = "parent-folder-id")
}
## ------------------------------------------------
## Method `File$list_contents`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# List folder's content
file_object$list_contents()
}
## ------------------------------------------------
## Method `File$delete`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Delete file object
file_object$delete()
}
## ------------------------------------------------
## Method `File$download`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Download file object
file_object$download(directory_path = ".")
}
## ------------------------------------------------
## Method `File$submit_export`
## ------------------------------------------------
if (FALSE) {
# x is API response when file is requested
file_object <- File$new(
res = x,
href = x$href,
auth = auth,
response = attr(x, "response")
)
# Export file object to a volume
file_object$submit_export(
destination_volume = volume,
destination_location = location
)
}