The cp command is the preferred method to copy files into and out of the DAMs. For adding data, the cp command covers both PUT requests and POST in the LDP specification.
--mime-type=[mime-type]. Equivalant to -header=ContentType: [mime-type], used for either URL in the copy command
-H | --header= Specify additional headers for any URL requests
Put vs. Post
Fedora has two different methods for adding data to a repository, PUT and POST. The main difference between them being that PUT requires filenames to be preserved, while POST allows the system to make those changes.
Put
From the Fedora Docs PUT creates a resource with a specified path, or replace the triples associated with a resource with the triples provided in the request body. So, PUT can be used for adding and replacing files. So for the
cp uri [fedora-name]. If the fedora-name exists, then if it's an ldp:Container the uri will be PUT as a new binary, using the basename of the uri as the binary name for the
cp uri [uris] [dir] will PUT the binaries specified by the uris into that specified container with the basenames from the URIs.
Files inside the F4 can be specified in three ways, either relative to the $CWD, as absolute paths, or with the prefix fedora://. The fedora
Files outside of F4 can be specified using URLs, with the file:// URL being used for the local filesystem. In addition, the file:/// URL can specify either absolutely, or relatively.
cp file:./foo.png foo.png # This copies foo.png from the local filesystem to Fedora
mime type
If the mime-type is not specified, then the type is taken to be equivalent to Content-Type header of the URI, or for local files, the equivalent to file --mime-type --brief [[filename]]. This should be the same as the npm mime-magic function.
Additional headers
The -H | --header allows additional headers to be included in the requests. These headers are associated with either the input or output URI. The are assoicated with the
# Copy a JSON representation of URL into the repo
cp https://foo.com/file -H'Accept: application/json' fedora://./bar
# Copy only the first 100 byte from a fedora file
cp bar -H'Range: bytes=0-=100` file://./some.txt
### /dev/stdin /dev/stdout
In non-interactive example, /dev/stdin or stdout work as . For the interactive terminal, these should connect to the interactive terminal session. It would be great if we can use the standard bash constructs for that, but it's not required. At least be able to Ctrl-D to stop entry.
```{bash}
# Non Interactive Examples
fccli cp file:///dev/stdin fedora://./bar <<< 'Example Here'
fccli cp file:///dev/stdin fedora://.bar <<EOF
Long Example
Here
EOF
# Get the HEAD of a file
fccli cp bar -H'Range: 1-100bytes' file:///dev/stdout
Note, this is similar behavior to curl file:///dev/stdin
cp
Copying files into and out of fedoraThe
cp
command is the preferred method to copy files into and out of the DAMs. For adding data, thecp
command covers both PUT requests and POST in the LDP specification.--mime-type=[mime-type]
. Equivalant to-header=ContentType: [mime-type]
, used for either URL in the copy command-H | --header=
Specify additional headers for any URL requestsPut vs. Post
Fedora has two different methods for adding data to a repository, PUT and POST. The main difference between them being that PUT requires filenames to be preserved, while POST allows the system to make those changes.
Put
From the Fedora Docs PUT creates a resource with a specified path, or replace the triples associated with a resource with the triples provided in the request body. So, PUT can be used for adding and replacing files. So for the
cp uri [fedora-name]
. If the fedora-name exists, then if it's an ldp:Container the uri will be PUT as a new binary, using the basename of the uri as the binary name for thecp uri [uris] [dir]
will PUT the binaries specified by the uris into that specified container with the basenames from the URIs.So
Post
From the Fedora Docs POST
file naming
Files inside the F4 can be specified in three ways, either relative to the $CWD, as absolute paths, or with the prefix
fedora://
. The fedoraFiles outside of F4 can be specified using URLs, with the
file://
URL being used for the local filesystem. In addition, the file:/// URL can specify either absolutely, or relatively.mime type
If the mime-type is not specified, then the type is taken to be equivalent to Content-Type header of the URI, or for local files, the equivalent to
file --mime-type --brief [[filename]]
. This should be the same as the npm mime-magic function.Additional headers
The
-H | --header
allows additional headers to be included in the requests. These headers are associated with either the input or output URI. The are assoicated with theNote, this is similar behavior to
curl file:///dev/stdin