Upload files to the HTTP API directly from the terminal
The easiest way to upload files to the service without using a web browser is to download the command line utility for your operating system:
curl https://upload.elastic.co/s/eluploader_darwin_amd64 -o eluploader
Make the utility executable:
chmod +x eluploader
Then, pass it the upload ID or URL and the path to your file:
./eluploader -u f95ec1a2-acf5-4e2c-92e0-09408848cf06 /tmp/myfile.tar.gz
The utility will compute the SHA256 digest of your file, split it into parts, and upload them in parallel to the service.
When you cannot use the command line utility, you can interact with the service API directly, using the standard curl
command line HTTP client.
However, you have to perform additional steps, such as computing the file digest and splitting it into parts.
For the purposes of this guide, we'll assume the file you want to upload is in the current directory; we'll use the Ubuntu Linux Server ISO distribution file (ubuntu-18.04-live-server-amd64.iso
) as an example.
First, export the API endpoint as an environment variable:
export UPLOAD_HOST="https://upload.elastic.co"
Then, the upload ID:
export UPLOAD_ID="f95ec1a2-acf5-4e2c-92e0-09408848cf06"
Export the path to the file you want to upload:
export UPLOAD_FILE="$HOME/Downloads/ubuntu-18.04-live-server-amd64.iso"
Compute and export the SHA256 file digest as well:
export UPLOAD_FILE_DIGEST=$(shasum -a 256 $UPLOAD_FILE | cut -c1-64)
Finally, split the file into parts of 50MBs each:
FILESIZE=$(stat -F $UPLOAD_FILE | cut -d " " -f5)
MAXSIZE=50000000
if [[ "$FILESIZE" < "$MAXSIZE" ]]; then cp $UPLOAD_FILE part-aa; else split -b 50m $UPLOAD_FILE part-; fi
In our example, there are now 17 part files:
ls -l part-* | wc -l
# => 17
Using the following script, upload each part with the curl
tool:
pn=1; for f in part-*
do
fd=$UPLOAD_FILE_DIGEST
fn=$(basename $UPLOAD_FILE)
echo
echo ">>> Part $pn: $f"
pd=$(shasum -a 256 $f | cut -c1-64)
echo " SHA256: $pd"
curl -s -f -o /dev/null -I "$UPLOAD_HOST/api/uploads/$UPLOAD_ID/$UPLOAD_FILE_DIGEST/$pd"
if [ $? -ne 0 ]; then
echo -n " Result: "
curl -f -s -X PUT -w "\n Status: %{http_code}\n" \
"$UPLOAD_HOST/api/uploads/$UPLOAD_ID?part_number=$pn&part_digest=$pd&file_digest=$fd&filename=$fn" \
--data-binary @"$f"
if [[ $? -ne 0 ]]; then
echo -e "<<< \033[31m[ERROR]\033[0m"
else
echo -e "<<< \033[32m[OK]\033[0m"
fi
else
echo -e "<<< \033[33m[SKIPPED]\033[0m"
fi
echo
pn=$((pn+1))
done
You should an output like this in your terminal:
>>> Part 1: part-aa
SHA256: 0ad2ffd10b29b16fdfb55735bd6389f6e21327780d2d1e09cc2ac7371a55e8fb
Result: {"id" : "0ad2ff...", "part_number" : 1, "bytes_written" : 52428800}
Status: 201
<<< [OK]
>>> Part 2: part-ab
SHA256: c6e93f1b045a2df296a83a119a19cf1644b56b4bc9ccc0a217830bbd09ad49a4
Result: {"id" : "c6e93f...", "part_number" : 2, "bytes_written" : 52428800}
Status: 201
<<< [OK]
...
If you see any [ERROR]
output from the script, just run it again — already uploaded parts will be skipped.
To indicate that all parts of the file have been completely and successfully completed, finalize the file:
curl -f -X POST "$UPLOAD_HOST/api/uploads/$UPLOAD_ID/$UPLOAD_FILE_DIGEST/_finalize" && $([[ $? -eq 0 ]]) && echo -e "\n\033[32m[FILE SUCCESSFULLY UPLOADED]\033[0m"
You should see the [FILE SUCCESSFULLY UPLOADED]
message in your console — if you see any errors, try running the same command again.
Optionally, verify that the file exists and the metadata are correct:
curl -i -f -I "$UPLOAD_HOST/api/uploads/$UPLOAD_ID/$UPLOAD_FILE_DIGEST"
You should see a successful HTTP response in your terminal:
HTTP/1.1 200 OK
Content-Disposition: attachment; filename="ubuntu-18.04-live-server-amd64.iso"
Content-Length: 845152256
Content-Type: application/octect-stream
Etag: "7a1c2966f82268c14560386fbc467d58c3fbd2793f3b1f657baee609b80d39a8"
...
The recipient has been notified that the file is ready for download.
The easiest way to upload files to the service without using a web browser is to download the the command line utility for your operating system:
https://upload.elastic.co/s/eluploader_windows_amd64.exe
Then, pass it the upload ID or URL and the path to your file:
eluploader_windows_amd64.exe -u f95ec1a2-acf5-4e2c-92e0-09408848cf06 C:\Temp\myfile.zip
The utility will compute the SHA256 digest of your file, split it into parts, and upload them in parallel to the service.
Coming soon
The easiest way to upload files to the service without using a web browser is to download the the command line utility for your operating system:
curl https://upload.elastic.co/s/eluploader_linux_amd64 -o eluploader
Or:
curl https://upload.elastic.co/s/eluploader_linux_arm64 -o eluploader
Make the utility executable:
chmod +x eluploader
Then, pass it the upload ID or URL and the path to your file:
./eluploader -u f95ec1a2-acf5-4e2c-92e0-09408848cf06 /tmp/myfile.tar.gz
The utility will compute the SHA256 digest of your file, split it into parts, and upload them in parallel to the service.
When you cannot use the command line utility, you can interact with the service API directly, using the standard curl
command line HTTP client.
However, you have to perform additional steps, such as computing the file digest and splitting it into parts.
For the purposes of this guide, we'll assume the file you want to upload is in the current directory; we'll use the Ubuntu Linux Server ISO distribution file (ubuntu-18.04-live-server-amd64.iso
) as an example.
First, export the API endpoint as an environment variable:
export UPLOAD_HOST="https://upload.elastic.co"
Then, the upload ID:
export UPLOAD_ID="f95ec1a2-acf5-4e2c-92e0-09408848cf06"
Export the path to the file you want to upload:
export UPLOAD_FILE="$HOME/Downloads/ubuntu-18.04-live-server-amd64.iso"
Compute and export the SHA256 file digest as well:
export UPLOAD_FILE_DIGEST=$(shasum -a 256 $UPLOAD_FILE | cut -c1-64)
Finally, split the file into parts of 50MBs each:
FILESIZE=$(stat -c %s $UPLOAD_FILE)
MAXSIZE=50000000
if [[ $FILESIZE -lt $MAXSIZE ]]; then cp $UPLOAD_FILE part-aa; else split -b 50m $UPLOAD_FILE part-; fi
In our example, there are now 17 part files:
ls -l part-* | wc -l
# => 17
Using the following script, upload each part with the curl
tool:
pn=1; for f in part-*
do
fd=$UPLOAD_FILE_DIGEST
fn=$(basename $UPLOAD_FILE)
echo
echo ">>> Part $pn: $f"
pd=$(shasum -a 256 $f | cut -c1-64)
echo " SHA256: $pd"
curl -s -f -o /dev/null -I "$UPLOAD_HOST/api/uploads/$UPLOAD_ID/$UPLOAD_FILE_DIGEST/$pd"
if [ $? -ne 0 ]; then
echo -n " Result: "
curl -f -s -X PUT -w "\n Status: %{http_code}\n" \
"$UPLOAD_HOST/api/uploads/$UPLOAD_ID?part_number=$pn&part_digest=$pd&file_digest=$fd&filename=$fn" \
--data-binary @"$f"
if [[ $? -ne 0 ]]; then
echo -e "<<< \033[31m[ERROR]\033[0m"
else
echo -e "<<< \033[32m[OK]\033[0m"
fi
else
echo -e "<<< \033[33m[SKIPPED]\033[0m"
fi
echo
pn=$((pn+1))
done
You should an output like this in your terminal:
>>> Part 1: part-aa
SHA256: 0ad2ffd10b29b16fdfb55735bd6389f6e21327780d2d1e09cc2ac7371a55e8fb
Result: {"id" : "0ad2ff...", "part_number" : 1, "bytes_written" : 52428800}
Status: 201
<<< [OK]
>>> Part 2: part-ab
SHA256: c6e93f1b045a2df296a83a119a19cf1644b56b4bc9ccc0a217830bbd09ad49a4
Result: {"id" : "c6e93f...", "part_number" : 2, "bytes_written" : 52428800}
Status: 201
<<< [OK]
...
If you see any [ERROR]
output from the script, just run it again — already uploaded parts will be skipped.
To indicate that all parts of the file have been completely and successfully completed, finalize the file:
curl -f -X POST "$UPLOAD_HOST/api/uploads/$UPLOAD_ID/$UPLOAD_FILE_DIGEST/_finalize" && $([[ $? -eq 0 ]]) && echo -e "\n\033[32m[FILE SUCCESSFULLY UPLOADED]\033[0m"
You should see the [FILE SUCCESSFULLY UPLOADED]
message in your console — if you see any errors, try running the same command again.
Optionally, verify that the file exists and the metadata are correct:
curl -i -f -I "$UPLOAD_HOST/api/uploads/$UPLOAD_ID/$UPLOAD_FILE_DIGEST"
You should see a successful HTTP response in your terminal:
HTTP/1.1 200 OK
Content-Disposition: attachment; filename="ubuntu-18.04-live-server-amd64.iso"
Content-Length: 845152256
Content-Type: application/octect-stream
Etag: "7a1c2966f82268c14560386fbc467d58c3fbd2793f3b1f657baee609b80d39a8"
...
The recipient has been notified that the file is ready for download.
The information that you are providing to Elastic may contain personal data or other sensitive (i.e., highly confidential) data that may not be shared with third parties under your company's information security policies or under applicable law. Elastic does not require and does not wish to receive such personal or other sensitive data. Further, Elastic cannot review this information prior to uploading to ensure no such personal or sensitive data is included; nor will Elastic review the information after it has been uploaded to determine whether any personal or sensitive data has been included.
Accordingly, you represent that:
(i) your uploading of information to Elastic is in compliance with your company's information security policies and applicable law and
(ii) you have reviewed the information before uploading and removed any personal or sensitive data that may be included in such information prior to providing it to us.
If the information you will provide to Elastic contains personal data that cannot be removed, please notify your Elastic support engineer prior to providing such information to Elastic.
If you provide to Elastic any files, libraries or programs that are subject to third party license terms, you represent that you have obtained adequate rights to share such files, libraries or programs with us.