Repository navigation
Expand file tree
/
Copy pathls
More file actions
79 lines (52 loc) · 2.11 KB
/
Copy pathls
File metadata and controls
79 lines (52 loc) · 2.11 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# FoundationFS
FoundationFS is a File Storage system for FoundationDB written in go
intended to mimic mongodb gridfs file storage layer.
Includes an example http server interface with support for basic upload and download of any file type.
## Installation
```bash
go get github.com/cloudmode/FoundationFS
```
## Dependencies
FoundationFS requires:
Go 1.1+ with CGO enabled
FoundationDB C API 2.0.x or 3.0.x (part of the FoundationDB clients package)
Use of this package requires the selection of a FoundationDB API version at runtime. This package currently supports FoundationDB API versions 200 and 300 (although version 300 requires a 3.0.x FoundationDB C library to be installed).
To install the fdb-go package interface (https://github.com/FoundationDB/fdb-go):
```bash
go get github.com/FoundationDB/fdb-go/fdb
```
FoundationFS uses go/codec (using the msgpack codec) for storing values in FDB
such as the file meta data. (https://github.com/ugorji/go)
To install the go/codec package:
```bash
go get github.com/ugorji/go/codec
```
Other dependencies:
```bash
go get github.com/twinj/uuid
```
## Example
To run the example:
```bash
cd examples
go run simple.go
```
The server will be listening on localhost:9090. Direct your browser to localhost:9090/upload, upload
a file and json with the id of the uploaded file returned. Copy and paste the id of the uploaded file
into http://localhost:9090/download?id=<the id returned> and the file will be displayed in your browser
To test with curl:
```bash
curl -i -X POST -H "Content-Type: multipart/form-data" -F "uploadfile=@test.png" http://localhost:9090/upload
curl -o foo.png http://localhost:9090/download?id=<the id returned from previous curl POST>
```
## Test Suite
The test suite uses the standard go test runner along with convey, download here.
```bash
go get github.com/smartystreets/goconvey/convey
cd test
go test
```
The test script expects there to be at least one file in the test/data subdirectory which is used
for uploading and downloading tests. It will fail if there are no files in data.
## License
The MIT License (MIT) - see LICENSE.md for more details