<commit_before>#!/bin/bash
#
# This script demonstrates basic interaction with tusd form BASH/curl.
# Can also be used as a simple way to test, or extend to see how it
# responds to edge cases or learn the basic tech.
#

# Constants
SERVICE="localhost:1080"

# Environment
set -e
__FILE__="$(test -L "${0}" && readlink "${0}" || echo "${0}")"
__DIR__="$(cd "$(dirname "${__FILE__}")"; echo $(pwd);)"

# POST requests the upload location
echo -ne "POST '${SERVICE}' \t\t\t\t\t\t\t"
location=$(curl -s \
  --include \
  --request POST \
  --header 'Content-Range: bytes */26' \
${SERVICE}/files |awk -F': ' '/^Location/ {print $2}' |tr -d '\r')
# `tr -d '\r'` is required or location will have one in it ---^
echo "<-- Location: ${location}"


# PUT some data
echo -ne "PUT  '${SERVICE}${location}' \t\t"
status=$(curl -s \
  --include \
  --request PUT \
  --header 'Content-Length: 3' \
  --header 'Content-Range: bytes 0-2/26' \
  --data 'abc' \<commit_msg>Compatibility note<commit_after>#!/bin/bash
#
# This script demonstrates basic interaction with tusd form BASH/curl.
# Can also be used as a simple way to test, or extend to see how it
# responds to edge cases or learn the basic tech.
#
# Compatible with tus resumable upload protocol 0.1

# Constants
SERVICE="localhost:1080"

# Environment
set -e
__FILE__="$(test -L "${0}" && readlink "${0}" || echo "${0}")"
__DIR__="$(cd "$(dirname "${__FILE__}")"; echo $(pwd);)"

# POST requests the upload location
echo -ne "POST '${SERVICE}' \t\t\t\t\t\t\t"
location=$(curl -s \
  --include \
  --request POST \
  --header 'Content-Range: bytes */26' \
${SERVICE}/files |awk -F': ' '/^Location/ {print $2}' |tr -d '\r')
# `tr -d '\r'` is required or location will have one in it ---^
echo "<-- Location: ${location}"


# PUT some data
echo -ne "PUT  '${SERVICE}${location}' \t\t"
status=$(curl -s \
  --include \
  --request PUT \
  --header 'Content-Length: 3' \
  --header 'Content-Range: bytes 0-2/26' \
  --data 'abc' \
{'fraction_non_alphanumeric': 0.198682209832742, 'fraction_numerical': 0.016218955904713634, 'mean_word_length': 3.226980728051392, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1970130', 'n_tokens_mistral': 724, 'n_tokens_neox': 692, 'n_words': 242}