-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathupload-hook-example
More file actions
executable file
·46 lines (42 loc) · 1.23 KB
/
upload-hook-example
File metadata and controls
executable file
·46 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
#
# Example upload hook for filebin2.
#
# This script is called after a file has been successfully uploaded: both
# the S3 object and its database metadata have already been persisted. It
# is intended for notifications and post-processing such as an indexing
# job or a webhook.
#
# The hook does not affect the response to the client. Exit codes and
# stdout/stderr are logged by filebin2 but the upload is always reported
# as successful.
#
# Named arguments:
# --bin-id Bin ID
# --filename Filename
# --content-type Content type (MIME type)
# --size File size in bytes
# --sha256 SHA256 checksum of the file contents
#
# Usage:
# filebin2 --post-upload-hook /path/to/this/script
#
BIN=""
FILENAME=""
CONTENT_TYPE=""
FILE_SIZE=""
SHA256=""
while [ $# -gt 0 ]; do
case "$1" in
--bin-id) BIN="$2"; shift 2 ;;
--filename) FILENAME="$2"; shift 2 ;;
--content-type) CONTENT_TYPE="$2"; shift 2 ;;
--size) FILE_SIZE="$2"; shift 2 ;;
--sha256) SHA256="$2"; shift 2 ;;
*) shift ;;
esac
done
# Example: notify an external service
#curl -s -X POST -d "bin=$BIN&file=$FILENAME&size=$FILE_SIZE&sha256=$SHA256" \
# https://example.com/filebin-webhook
exit 0