Compare commits
6 Commits
741256c1e4
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d2923c276 | |||
| 70a23c0d55 | |||
| 73559fde88 | |||
| d303ec9154 | |||
| de5d5a2344 | |||
| 2ebe95e9f8 |
@@ -20,4 +20,6 @@ COPY --from=jsbuild /app/build/public /app/public
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT [ "/app/s3share" ]
|
||||
|
||||
@@ -12,7 +12,7 @@ Run `make` and the binary together with the web frontend will be in the `build`
|
||||
|
||||
# Usage
|
||||
|
||||
Run the `s3browser` binary with the `--help` flag to see the available options.
|
||||
Run the `s3share` binary with the `--help` flag to see the available options.
|
||||
The `public` directory needs to be in the same directory as the binary.
|
||||
|
||||
S3Share requires two things:
|
||||
@@ -20,6 +20,10 @@ S3Share requires two things:
|
||||
- a s3 bucket with read access
|
||||
- a sql database
|
||||
|
||||
## Docker
|
||||
|
||||
The docker image is available at [Dockerhub](https://hub.docker.com/r/djeeberjr/s3share). There is also a [docker-compose](docker-compose.yml) file that can be used as an example.
|
||||
|
||||
# Synopsis
|
||||
|
||||
```
|
||||
|
||||
@@ -19,8 +19,7 @@ type args struct {
|
||||
}
|
||||
|
||||
func (args) Version() string {
|
||||
// TODO
|
||||
return "s3share 0.1"
|
||||
return "s3share 1.0"
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
45
share.sh
Executable file
45
share.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
# This is an example on how i use this to upload and share files.
|
||||
# This is tested with minio.
|
||||
# You may need to change some things in here to fit your needs.
|
||||
|
||||
# Change these variables
|
||||
S3_BUCKET="bucketname"
|
||||
S3_ACCESS_KEY="accesskey"
|
||||
S3_SECRET_KEY="secretkey"
|
||||
S3_ENDPOINT="s3.example.com"
|
||||
ENDPOINT="https://share.example.com"
|
||||
API_USERNAME="admin"
|
||||
API_PASSWORD="hunter2"
|
||||
# Dont touch the things below
|
||||
|
||||
UPLOAD_FILE="$1"
|
||||
|
||||
if test -n "$1"; then
|
||||
UPLOAD_FILE=$1
|
||||
elif test ! -t 0; then
|
||||
read -r UPLOAD_FILE
|
||||
else
|
||||
>&2 echo "Provide a file"
|
||||
echo "Usage: $0 <file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UPLOAD_FILENAME=$(basename "$UPLOAD_FILE")
|
||||
|
||||
s3cmd -q -s --host "$S3_ENDPOINT" --host-bucket "$S3_ENDPOINT" --access_key "$S3_ACCESS_KEY" --secret_key "$S3_SECRET_KEY" put "$UPLOAD_FILE" s3://$S3_BUCKET/
|
||||
|
||||
SLUG=$(curl -s -u "$API_USERNAME:$API_PASSWORD" -X POST --header "Content-Type: application/json" \
|
||||
--data "{\"key\":\"$UPLOAD_FILENAME\"}" \
|
||||
"$ENDPOINT/api/share" | jq -r ".slug")
|
||||
|
||||
|
||||
MIME=$(file -i -b "$UPLOAD_FILE")
|
||||
if echo "$MIME" | grep "image" &> /dev/null; then
|
||||
printf "%s/s/%s.%s\n" "$ENDPOINT" "$SLUG" "${UPLOAD_FILENAME##*.}"
|
||||
else
|
||||
printf "%s/%s\n" "$ENDPOINT" "$SLUG"
|
||||
fi
|
||||
Reference in New Issue
Block a user