mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add s3 multipart upload
This commit is contained in:
parent
9b3bf0e46c
commit
164091c269
|
@ -3,6 +3,8 @@ package filer2
|
|||
import (
|
||||
"math"
|
||||
"sort"
|
||||
"hash/fnv"
|
||||
"fmt"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||
)
|
||||
|
@ -17,6 +19,18 @@ func TotalSize(chunks []*filer_pb.FileChunk) (size uint64) {
|
|||
return
|
||||
}
|
||||
|
||||
func ETag(chunks []*filer_pb.FileChunk) (etag string) {
|
||||
if len(chunks) == 1 {
|
||||
return chunks[0].ETag
|
||||
}
|
||||
|
||||
h := fnv.New32a()
|
||||
for _, c := range chunks {
|
||||
h.Write([]byte(c.ETag))
|
||||
}
|
||||
return fmt.Sprintf("%x", h.Sum32())
|
||||
}
|
||||
|
||||
func CompactFileChunks(chunks []*filer_pb.FileChunk) (compacted, garbage []*filer_pb.FileChunk) {
|
||||
|
||||
visibles := nonOverlappingVisibleIntervals(chunks)
|
||||
|
|
|
@ -76,6 +76,7 @@ message FileChunk {
|
|||
int64 offset = 2;
|
||||
uint64 size = 3;
|
||||
int64 mtime = 4;
|
||||
string e_tag = 5;
|
||||
}
|
||||
|
||||
message FuseAttributes {
|
||||
|
|
|
@ -239,6 +239,7 @@ type FileChunk struct {
|
|||
Offset int64 `protobuf:"varint,2,opt,name=offset" json:"offset,omitempty"`
|
||||
Size uint64 `protobuf:"varint,3,opt,name=size" json:"size,omitempty"`
|
||||
Mtime int64 `protobuf:"varint,4,opt,name=mtime" json:"mtime,omitempty"`
|
||||
ETag string `protobuf:"bytes,5,opt,name=e_tag,json=eTag" json:"e_tag,omitempty"`
|
||||
}
|
||||
|
||||
func (m *FileChunk) Reset() { *m = FileChunk{} }
|
||||
|
@ -274,6 +275,13 @@ func (m *FileChunk) GetMtime() int64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (m *FileChunk) GetETag() string {
|
||||
if m != nil {
|
||||
return m.ETag
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type FuseAttributes struct {
|
||||
FileSize uint64 `protobuf:"varint,1,opt,name=file_size,json=fileSize" json:"file_size,omitempty"`
|
||||
Mtime int64 `protobuf:"varint,2,opt,name=mtime" json:"mtime,omitempty"`
|
||||
|
@ -1130,81 +1138,82 @@ var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{
|
|||
func init() { proto.RegisterFile("filer.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 1202 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x6e, 0xdb, 0x46,
|
||||
0x10, 0x36, 0x49, 0x4b, 0x16, 0x47, 0x72, 0x1a, 0xaf, 0x9d, 0x84, 0x55, 0xec, 0x54, 0x61, 0x93,
|
||||
0xc2, 0x41, 0x0d, 0xc3, 0x70, 0x7b, 0x48, 0x1a, 0x14, 0x68, 0x60, 0x3b, 0x41, 0x00, 0xc7, 0x01,
|
||||
0xe8, 0xba, 0x40, 0xd1, 0x83, 0x40, 0x93, 0x23, 0x77, 0x61, 0x8a, 0x54, 0xc9, 0xa5, 0x1d, 0xf7,
|
||||
0x15, 0x7a, 0x69, 0x1f, 0xa0, 0xe7, 0xde, 0xfb, 0x00, 0xbd, 0xf4, 0xc5, 0x82, 0xfd, 0x21, 0xb5,
|
||||
0x14, 0x29, 0x27, 0x3e, 0xe4, 0xb6, 0x3b, 0x33, 0xfb, 0xcd, 0x0f, 0x67, 0xbe, 0x5d, 0x42, 0x77,
|
||||
0x44, 0x23, 0x4c, 0xb7, 0x27, 0x69, 0xc2, 0x12, 0xd2, 0x11, 0x9b, 0xe1, 0xe4, 0xd4, 0x7d, 0x0b,
|
||||
0xf7, 0x0f, 0x93, 0xe4, 0x3c, 0x9f, 0xec, 0xd3, 0x14, 0x03, 0x96, 0xa4, 0x57, 0x07, 0x31, 0x4b,
|
||||
0xaf, 0x3c, 0xfc, 0x2d, 0xc7, 0x8c, 0x91, 0x75, 0xb0, 0xc3, 0x42, 0xe1, 0x18, 0x03, 0x63, 0xd3,
|
||||
0xf6, 0xa6, 0x02, 0x42, 0x60, 0x31, 0xf6, 0xc7, 0xe8, 0x98, 0x42, 0x21, 0xd6, 0xee, 0x01, 0xac,
|
||||
0x37, 0x03, 0x66, 0x93, 0x24, 0xce, 0x90, 0x3c, 0x86, 0x16, 0x72, 0x81, 0x40, 0xeb, 0xee, 0x7e,
|
||||
0xb6, 0x5d, 0x84, 0xb2, 0x2d, 0xed, 0xa4, 0xd6, 0xfd, 0xcf, 0x00, 0x72, 0x48, 0x33, 0xc6, 0x85,
|
||||
0x14, 0xb3, 0x8f, 0x8b, 0xe7, 0x2e, 0xb4, 0x27, 0x29, 0x8e, 0xe8, 0x3b, 0x15, 0x91, 0xda, 0x91,
|
||||
0x2d, 0x58, 0xc9, 0x98, 0x9f, 0xb2, 0x97, 0x69, 0x32, 0x7e, 0x49, 0x23, 0x3c, 0xe2, 0x41, 0x5b,
|
||||
0xc2, 0xa4, 0xae, 0x20, 0xdb, 0x40, 0x68, 0x1c, 0x44, 0x79, 0x46, 0x2f, 0xf0, 0xb8, 0xd0, 0x3a,
|
||||
0x8b, 0x03, 0x63, 0xb3, 0xe3, 0x35, 0x68, 0xc8, 0x1a, 0xb4, 0x22, 0x3a, 0xa6, 0xcc, 0x69, 0x0d,
|
||||
0x8c, 0xcd, 0x65, 0x4f, 0x6e, 0xdc, 0x1f, 0x60, 0xb5, 0x12, 0xbf, 0x4a, 0xff, 0x09, 0x2c, 0xa1,
|
||||
0x14, 0x39, 0xc6, 0xc0, 0x6a, 0x2a, 0x40, 0xa1, 0x77, 0xff, 0x36, 0xa1, 0x25, 0x44, 0x65, 0x9d,
|
||||
0x8d, 0x69, 0x9d, 0xc9, 0x43, 0xe8, 0xd1, 0x6c, 0x38, 0x2d, 0x86, 0x29, 0xe2, 0xeb, 0xd2, 0xac,
|
||||
0xac, 0x3b, 0xf9, 0x1a, 0xda, 0xc1, 0xaf, 0x79, 0x7c, 0x9e, 0x39, 0x96, 0x70, 0xb5, 0x3a, 0x75,
|
||||
0xc5, 0x93, 0xdd, 0xe3, 0x3a, 0x4f, 0x99, 0x90, 0xa7, 0x00, 0x3e, 0x63, 0x29, 0x3d, 0xcd, 0x19,
|
||||
0x66, 0x22, 0xdb, 0xee, 0xae, 0xa3, 0x1d, 0xc8, 0x33, 0x7c, 0x51, 0xea, 0x3d, 0xcd, 0x96, 0x3c,
|
||||
0x83, 0x0e, 0xbe, 0x63, 0x18, 0x87, 0x18, 0x3a, 0x2d, 0xe1, 0x68, 0x63, 0x26, 0xa7, 0xed, 0x03,
|
||||
0xa5, 0x97, 0x19, 0x96, 0xe6, 0xfd, 0xe7, 0xb0, 0x5c, 0x51, 0x91, 0xdb, 0x60, 0x9d, 0x63, 0xf1,
|
||||
0x65, 0xf9, 0x92, 0x57, 0xf7, 0xc2, 0x8f, 0x72, 0xd9, 0x64, 0x3d, 0x4f, 0x6e, 0xbe, 0x33, 0x9f,
|
||||
0x1a, 0x6e, 0x02, 0x2b, 0x07, 0x17, 0x18, 0xb3, 0xa3, 0x84, 0xd1, 0x11, 0x0d, 0x7c, 0x46, 0x93,
|
||||
0x98, 0x6c, 0x81, 0x9d, 0x44, 0xe1, 0x50, 0xb6, 0x98, 0xd9, 0xdc, 0x62, 0x9d, 0x24, 0x52, 0xee,
|
||||
0xb6, 0xc0, 0x8e, 0xf1, 0x52, 0x59, 0x5b, 0x73, 0xac, 0x63, 0xbc, 0x14, 0x2b, 0x77, 0x04, 0x76,
|
||||
0x59, 0x37, 0x72, 0x0f, 0x96, 0xb8, 0xe1, 0x90, 0x86, 0x2a, 0xda, 0x36, 0xdf, 0xbe, 0x0e, 0x79,
|
||||
0x13, 0x26, 0xa3, 0x51, 0x86, 0x4c, 0xb8, 0xb7, 0x3c, 0xb5, 0xe3, 0x1f, 0x31, 0xa3, 0xbf, 0xcb,
|
||||
0xbe, 0x5b, 0xf4, 0xc4, 0x9a, 0x27, 0x37, 0x66, 0x74, 0x8c, 0xa2, 0xde, 0x96, 0x27, 0x37, 0xee,
|
||||
0x1f, 0x26, 0xdc, 0xaa, 0xd6, 0x9b, 0xdc, 0x07, 0x5b, 0x78, 0x13, 0x08, 0x86, 0x40, 0x10, 0x33,
|
||||
0x7c, 0x5c, 0x41, 0x31, 0x35, 0x94, 0xf2, 0xc8, 0x38, 0x09, 0xa5, 0xd3, 0x65, 0x79, 0xe4, 0x4d,
|
||||
0x12, 0x22, 0xaf, 0x73, 0x4e, 0x43, 0xe1, 0x76, 0xd9, 0xe3, 0x4b, 0x2e, 0x39, 0xa3, 0xa1, 0xea,
|
||||
0x61, 0xbe, 0xe4, 0x89, 0x04, 0xa9, 0xc0, 0x6d, 0xcb, 0x44, 0xe4, 0x8e, 0x27, 0x32, 0xe6, 0xd2,
|
||||
0x25, 0xd9, 0x8d, 0x7c, 0x4d, 0x06, 0xd0, 0x4d, 0x71, 0x12, 0xa9, 0xaf, 0xe0, 0x74, 0x84, 0x4a,
|
||||
0x17, 0x91, 0x07, 0x00, 0x41, 0x12, 0x45, 0x18, 0x08, 0x03, 0x5b, 0x18, 0x68, 0x12, 0x5e, 0x4f,
|
||||
0xc6, 0xa2, 0x61, 0x86, 0x81, 0x03, 0x03, 0x63, 0xb3, 0xe5, 0xb5, 0x19, 0x8b, 0x8e, 0x31, 0x70,
|
||||
0xcf, 0xe0, 0xf3, 0x57, 0x28, 0xe6, 0xe8, 0x4a, 0x6b, 0x40, 0xc5, 0x07, 0x4d, 0x93, 0xb1, 0x01,
|
||||
0x30, 0xf1, 0x53, 0x8c, 0x19, 0x9f, 0x0e, 0xc5, 0x04, 0xb6, 0x94, 0xec, 0xd3, 0x54, 0xff, 0x70,
|
||||
0x96, 0xfe, 0xe1, 0xdc, 0x3f, 0x4d, 0xe8, 0x37, 0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x79, 0x72, 0x33, 0x33, 0xf8, 0x66, 0x6d, 0xf0, 0x67, 0xa8,
|
||||
0xc3, 0xaa, 0x53, 0x87, 0x46, 0x0d, 0x8b, 0x3a, 0x35, 0x90, 0x2f, 0xa0, 0xcb, 0xd3, 0x1b, 0x06,
|
||||
0x18, 0x33, 0x4c, 0x45, 0x06, 0xb6, 0x07, 0x5c, 0xb4, 0x27, 0x24, 0xee, 0x05, 0xac, 0x55, 0x03,
|
||||
0x55, 0xbd, 0x38, 0x97, 0xbc, 0x39, 0x2f, 0xa6, 0x91, 0x8a, 0x92, 0x2f, 0x05, 0x9b, 0xe4, 0xa7,
|
||||
0x11, 0x0d, 0x86, 0x5c, 0x61, 0x29, 0x36, 0x11, 0x92, 0x93, 0x34, 0x9a, 0xe6, 0xbc, 0xa8, 0xe5,
|
||||
0xec, 0x7e, 0x0b, 0xab, 0xf2, 0x11, 0x54, 0x2d, 0xd0, 0x06, 0xc0, 0x85, 0x10, 0x0c, 0x69, 0x28,
|
||||
0xef, 0x7f, 0xdb, 0xb3, 0xa5, 0xe4, 0x75, 0x98, 0xb9, 0xdf, 0x83, 0x7d, 0x98, 0xc8, 0x9c, 0x33,
|
||||
0xb2, 0x03, 0x76, 0x54, 0x6c, 0xd4, 0x53, 0x81, 0x4c, 0x5b, 0xae, 0xb0, 0xf3, 0xa6, 0x46, 0xee,
|
||||
0x73, 0xe8, 0x14, 0xe2, 0x22, 0x0f, 0x63, 0x5e, 0x1e, 0xe6, 0x4c, 0x1e, 0xee, 0xff, 0x06, 0xac,
|
||||
0x55, 0x43, 0x56, 0xa5, 0x3a, 0x81, 0xe5, 0xd2, 0xc5, 0x70, 0xec, 0x4f, 0x54, 0x2c, 0x3b, 0x7a,
|
||||
0x2c, 0xf5, 0x63, 0x65, 0x80, 0xd9, 0x1b, 0x7f, 0x22, 0xbb, 0xa7, 0x17, 0x69, 0xa2, 0xfe, 0x8f,
|
||||
0xb0, 0x52, 0x33, 0x69, 0xa0, 0xa6, 0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36, 0xad, 0xda, 0xa4, 0xf4, 0xdd, 0xeb, 0x4c, 0x0a, 0xf0, 0xd3, 0xb6,
|
||||
0xf8, 0x93, 0xfc, 0xe6, 0x7d, 0x00, 0x00, 0x00, 0xff, 0xff, 0x37, 0xca, 0xa4, 0x46, 0x58, 0x0e,
|
||||
// 1218 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x6e, 0xdb, 0xc6,
|
||||
0x13, 0x37, 0xa9, 0x0f, 0x8b, 0x23, 0x39, 0xff, 0x78, 0xe5, 0x24, 0xfc, 0x2b, 0x76, 0xaa, 0xb0,
|
||||
0x49, 0xe1, 0xa0, 0x86, 0x61, 0xb8, 0x3d, 0x24, 0x0d, 0x0a, 0x34, 0xb0, 0x9d, 0x20, 0x80, 0xe3,
|
||||
0x00, 0x74, 0x5c, 0xa0, 0xe8, 0x41, 0xa0, 0xc9, 0xb1, 0xba, 0x30, 0x45, 0xaa, 0xe4, 0xd2, 0x8e,
|
||||
0xdb, 0x47, 0xe8, 0xa5, 0x7d, 0x80, 0x9e, 0x7b, 0xef, 0x03, 0xf4, 0xd2, 0x17, 0x2b, 0xf6, 0x83,
|
||||
0xd4, 0x52, 0xa4, 0x9c, 0xf8, 0x90, 0xdb, 0xee, 0xcc, 0xec, 0xcc, 0x6f, 0x86, 0x33, 0xbf, 0x5d,
|
||||
0x42, 0xf7, 0x8c, 0x86, 0x98, 0x6c, 0x4f, 0x93, 0x98, 0xc5, 0xa4, 0x23, 0x36, 0xa3, 0xe9, 0xa9,
|
||||
0xf3, 0x16, 0xee, 0x1f, 0xc6, 0xf1, 0x79, 0x36, 0xdd, 0xa7, 0x09, 0xfa, 0x2c, 0x4e, 0xae, 0x0e,
|
||||
0x22, 0x96, 0x5c, 0xb9, 0xf8, 0x73, 0x86, 0x29, 0x23, 0xeb, 0x60, 0x05, 0xb9, 0xc2, 0x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x43, 0x84, 0xea,
|
||||
0xcf, 0x42, 0xf1, 0x64, 0xf7, 0xb8, 0xce, 0x55, 0x26, 0xe4, 0x29, 0x80, 0xc7, 0x58, 0x42, 0x4f,
|
||||
0x33, 0x86, 0xa9, 0xc8, 0xb6, 0xbb, 0x6b, 0x6b, 0x07, 0xb2, 0x14, 0x5f, 0x14, 0x7a, 0x57, 0xb3,
|
||||
0x25, 0xcf, 0xa0, 0x83, 0xef, 0x19, 0x46, 0x01, 0x06, 0x76, 0x4b, 0x04, 0xda, 0x98, 0xcb, 0x69,
|
||||
0xfb, 0x40, 0xe9, 0x65, 0x86, 0x85, 0xf9, 0xe0, 0x39, 0xac, 0x94, 0x54, 0xe4, 0x36, 0x34, 0xce,
|
||||
0x31, 0xff, 0xb2, 0x7c, 0xc9, 0xab, 0x7b, 0xe1, 0x85, 0x99, 0x6c, 0xb2, 0x9e, 0x2b, 0x37, 0xdf,
|
||||
0x98, 0x4f, 0x0d, 0x27, 0x86, 0xd5, 0x83, 0x0b, 0x8c, 0xd8, 0x51, 0xcc, 0xe8, 0x19, 0xf5, 0x3d,
|
||||
0x46, 0xe3, 0x88, 0x6c, 0x81, 0x15, 0x87, 0xc1, 0x48, 0xb6, 0x98, 0x59, 0xdf, 0x62, 0x9d, 0x38,
|
||||
0x54, 0xe1, 0xb6, 0xc0, 0x8a, 0xf0, 0x52, 0x59, 0x37, 0x16, 0x58, 0x47, 0x78, 0x29, 0x56, 0xce,
|
||||
0xaf, 0x60, 0x15, 0x75, 0x23, 0xf7, 0x60, 0x99, 0x1b, 0x8e, 0x68, 0xa0, 0xd0, 0xb6, 0xf9, 0xf6,
|
||||
0x75, 0xc0, 0x9b, 0x30, 0x3e, 0x3b, 0x4b, 0x91, 0x89, 0xf0, 0x0d, 0x57, 0xed, 0xf8, 0x47, 0x4c,
|
||||
0xe9, 0x2f, 0xb2, 0xef, 0x9a, 0xae, 0x58, 0xf3, 0xe4, 0x26, 0x8c, 0x4e, 0x50, 0xd4, 0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x06, 0xdf, 0xac, 0x0c, 0xfe,
|
||||
0x1c, 0x75, 0x34, 0xaa, 0xd4, 0xa1, 0x51, 0x43, 0x53, 0xa7, 0x06, 0xf2, 0x19, 0x74, 0x79, 0x7a,
|
||||
0x23, 0x1f, 0x23, 0x86, 0x89, 0xe2, 0x50, 0xe0, 0xa2, 0x3d, 0x21, 0x71, 0x2e, 0x60, 0xad, 0x0c,
|
||||
0x54, 0xf5, 0xe2, 0x42, 0x46, 0xe7, 0xbc, 0x98, 0x84, 0x0a, 0x25, 0x5f, 0x0a, 0x36, 0xc9, 0x4e,
|
||||
0x43, 0xea, 0x8f, 0xb8, 0xa2, 0xa1, 0xd8, 0x44, 0x48, 0x4e, 0x92, 0x70, 0x96, 0x73, 0x53, 0xcb,
|
||||
0xd9, 0xf9, 0x1a, 0xfa, 0xf2, 0x65, 0x54, 0x2e, 0xd0, 0x06, 0xc0, 0x85, 0x10, 0x8c, 0x68, 0x20,
|
||||
0x1f, 0x05, 0x96, 0x6b, 0x49, 0xc9, 0xeb, 0x20, 0x75, 0xbe, 0x05, 0xeb, 0x30, 0x96, 0x39, 0xa7,
|
||||
0x64, 0x07, 0xac, 0x30, 0xdf, 0xa8, 0xf7, 0x03, 0x99, 0xb5, 0x5c, 0x6e, 0xe7, 0xce, 0x8c, 0x9c,
|
||||
0xe7, 0xd0, 0xc9, 0xc5, 0x79, 0x1e, 0xc6, 0xa2, 0x3c, 0xcc, 0xb9, 0x3c, 0x9c, 0x7f, 0x0d, 0x58,
|
||||
0x2b, 0x43, 0x56, 0xa5, 0x3a, 0x81, 0x95, 0x22, 0xc4, 0x68, 0xe2, 0x4d, 0x15, 0x96, 0x1d, 0x1d,
|
||||
0x4b, 0xf5, 0x58, 0x01, 0x30, 0x7d, 0xe3, 0x4d, 0x65, 0xf7, 0xf4, 0x42, 0x4d, 0x34, 0x78, 0x07,
|
||||
0xab, 0x15, 0x93, 0x1a, 0x6a, 0x7a, 0xa2, 0x53, 0x53, 0x89, 0x39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65, 0xe0, 0x5c, 0x67, 0x92, 0x3b, 0x3f, 0x6d,
|
||||
0x8b, 0xdf, 0xcb, 0xaf, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xe3, 0x2a, 0x44, 0x6d, 0x0e,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
package s3api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"strings"
|
||||
"strconv"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/satori/go.uuid"
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/filer2"
|
||||
)
|
||||
|
||||
func (s3a *S3ApiServer) createMultipartUpload(input *s3.CreateMultipartUploadInput) (output *s3.CreateMultipartUploadOutput, code ErrorCode) {
|
||||
|
@ -32,19 +39,76 @@ func (s3a *S3ApiServer) createMultipartUpload(input *s3.CreateMultipartUploadInp
|
|||
}
|
||||
|
||||
func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploadInput) (output *s3.CompleteMultipartUploadOutput, code ErrorCode) {
|
||||
|
||||
uploadDirectory := s3a.genUploadsFolder(*input.Bucket) + "/" + *input.UploadId
|
||||
|
||||
entries, err := s3a.list(uploadDirectory, "", "", false, 0)
|
||||
if err != nil {
|
||||
glog.Errorf("completeMultipartUpload %s *s error: %v", *input.Bucket, *input.UploadId, err)
|
||||
return nil, ErrNoSuchUpload
|
||||
}
|
||||
|
||||
var finalParts []*filer_pb.FileChunk
|
||||
var offset int64
|
||||
|
||||
for _, entry := range entries {
|
||||
if strings.HasSuffix(entry.Name, ".part") && !entry.IsDirectory {
|
||||
for _, chunk := range entry.Chunks {
|
||||
finalParts = append(finalParts, &filer_pb.FileChunk{
|
||||
FileId: chunk.FileId,
|
||||
Offset: offset,
|
||||
Size: chunk.Size,
|
||||
Mtime: chunk.Mtime,
|
||||
ETag: chunk.ETag,
|
||||
})
|
||||
offset += int64(chunk.Size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entryName := filepath.Base(*input.Key)
|
||||
dirName := filepath.Dir(*input.Key)
|
||||
if dirName == "." {
|
||||
dirName = ""
|
||||
}
|
||||
dirName = fmt.Sprintf("%s/%s/%s", s3a.option.BucketsPath, *input.Bucket, dirName)
|
||||
|
||||
err = s3a.mkFile(dirName, entryName, finalParts)
|
||||
|
||||
if err != nil {
|
||||
glog.Errorf("completeMultipartUpload %s/%s error: %v", dirName, entryName, err)
|
||||
return nil, ErrInternalError
|
||||
}
|
||||
|
||||
output = &s3.CompleteMultipartUploadOutput{
|
||||
Bucket: input.Bucket,
|
||||
ETag: aws.String("\"" + filer2.ETag(finalParts) + "\""),
|
||||
Key: input.Key,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s3a *S3ApiServer) abortMultipartUpload(input *s3.AbortMultipartUploadInput) (output *s3.AbortMultipartUploadOutput, code ErrorCode) {
|
||||
return
|
||||
|
||||
exists, err := s3a.exists(s3a.genUploadsFolder(*input.Bucket), *input.UploadId, true)
|
||||
if err != nil {
|
||||
glog.V(1).Infof("bucket %s abort upload %s: %v", *input.Bucket, *input.UploadId, err)
|
||||
return nil, ErrNoSuchUpload
|
||||
}
|
||||
if exists {
|
||||
err = s3a.rm(s3a.genUploadsFolder(*input.Bucket), *input.UploadId, true, true, true)
|
||||
}
|
||||
if err != nil {
|
||||
glog.V(1).Infof("bucket %s remove upload %s: %v", *input.Bucket, *input.UploadId, err)
|
||||
return nil, ErrInternalError
|
||||
}
|
||||
|
||||
return &s3.AbortMultipartUploadOutput{}, ErrNone
|
||||
}
|
||||
|
||||
func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput) (output *s3.ListMultipartUploadsOutput, code ErrorCode) {
|
||||
entries, err := s3a.list(s3a.genUploadsFolder(*input.Bucket))
|
||||
if err != nil {
|
||||
glog.Errorf("listMultipartUploads %s error: %v", *input.Bucket, err)
|
||||
return nil, ErrNoSuchUpload
|
||||
}
|
||||
|
||||
output = &s3.ListMultipartUploadsOutput{
|
||||
Bucket: input.Bucket,
|
||||
Delimiter: input.Delimiter,
|
||||
|
@ -53,6 +117,13 @@ func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput
|
|||
MaxUploads: input.MaxUploads,
|
||||
Prefix: input.Prefix,
|
||||
}
|
||||
|
||||
entries, err := s3a.list(s3a.genUploadsFolder(*input.Bucket), *input.Prefix, *input.KeyMarker, true, int(*input.MaxUploads))
|
||||
if err != nil {
|
||||
glog.Errorf("listMultipartUploads %s error: %v", *input.Bucket, err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if entry.Extended != nil {
|
||||
key := entry.Extended["key"]
|
||||
|
@ -66,5 +137,37 @@ func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput
|
|||
}
|
||||
|
||||
func (s3a *S3ApiServer) listObjectParts(input *s3.ListPartsInput) (output *s3.ListPartsOutput, code ErrorCode) {
|
||||
output = &s3.ListPartsOutput{
|
||||
Bucket: input.Bucket,
|
||||
Key: input.Key,
|
||||
UploadId: input.UploadId,
|
||||
MaxParts: input.MaxParts, // the maximum number of parts to return.
|
||||
PartNumberMarker: input.PartNumberMarker, // the part number starts after this, exclusive
|
||||
}
|
||||
|
||||
entries, err := s3a.list(s3a.genUploadsFolder(*input.Bucket)+"/"+*input.UploadId,
|
||||
"", fmt.Sprintf("%04d.part", *input.PartNumberMarker), false, int(*input.MaxParts))
|
||||
if err != nil {
|
||||
glog.Errorf("listObjectParts %s *s error: %v", *input.Bucket, *input.UploadId, err)
|
||||
return nil, ErrNoSuchUpload
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if strings.HasSuffix(entry.Name, ".part") && !entry.IsDirectory {
|
||||
partNumberString := entry.Name[:len(entry.Name)-len(".part")]
|
||||
partNumber, err := strconv.Atoi(partNumberString)
|
||||
if err != nil {
|
||||
glog.Errorf("listObjectParts %s *s parse %s: %v", *input.Bucket, *input.UploadId, entry.Name, err)
|
||||
continue
|
||||
}
|
||||
output.Parts = append(output.Parts, &s3.Part{
|
||||
PartNumber: aws.Int64(int64(partNumber)),
|
||||
LastModified: aws.Time(time.Unix(entry.Attributes.Mtime, 0)),
|
||||
Size: aws.Int64(int64(filer2.TotalSize(entry.Chunks))),
|
||||
ETag: aws.String("\"" + filer2.ETag(entry.Chunks) + "\""),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func (s3a *S3ApiServer) mkdir(parentDirectoryPath string, dirName string, fn fun
|
|||
Entry: entry,
|
||||
}
|
||||
|
||||
glog.V(1).Infof("create bucket: %v", request)
|
||||
glog.V(1).Infof("mkdir: %v", request)
|
||||
if _, err := client.CreateEntry(context.Background(), request); err != nil {
|
||||
return fmt.Errorf("mkdir %s/%s: %v", parentDirectoryPath, dirName, err)
|
||||
}
|
||||
|
@ -43,12 +43,46 @@ func (s3a *S3ApiServer) mkdir(parentDirectoryPath string, dirName string, fn fun
|
|||
})
|
||||
}
|
||||
|
||||
func (s3a *S3ApiServer) list(parentDirectoryPath string) (entries []*filer_pb.Entry, err error) {
|
||||
func (s3a *S3ApiServer) mkFile(parentDirectoryPath string, fileName string, chunks []*filer_pb.FileChunk) error {
|
||||
return s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||
|
||||
entry := &filer_pb.Entry{
|
||||
Name: fileName,
|
||||
IsDirectory: false,
|
||||
Attributes: &filer_pb.FuseAttributes{
|
||||
Mtime: time.Now().Unix(),
|
||||
Crtime: time.Now().Unix(),
|
||||
FileMode: uint32(0770),
|
||||
Uid: OS_UID,
|
||||
Gid: OS_GID,
|
||||
},
|
||||
Chunks: chunks,
|
||||
}
|
||||
|
||||
request := &filer_pb.CreateEntryRequest{
|
||||
Directory: parentDirectoryPath,
|
||||
Entry: entry,
|
||||
}
|
||||
|
||||
glog.V(1).Infof("create file: %s/%s", parentDirectoryPath, fileName)
|
||||
if _, err := client.CreateEntry(context.Background(), request); err != nil {
|
||||
return fmt.Errorf("create file %s/%s: %v", parentDirectoryPath, fileName, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s3a *S3ApiServer) list(parentDirectoryPath, prefix, startFrom string, inclusive bool, limit int) (entries []*filer_pb.Entry, err error) {
|
||||
|
||||
err = s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||
|
||||
request := &filer_pb.ListEntriesRequest{
|
||||
Directory: s3a.option.BucketsPath,
|
||||
Directory: s3a.option.BucketsPath,
|
||||
Prefix: prefix,
|
||||
StartFromFileName: startFrom,
|
||||
InclusiveStartFrom: inclusive,
|
||||
Limit: uint32(limit),
|
||||
}
|
||||
|
||||
glog.V(4).Infof("read directory: %v", request)
|
||||
|
@ -101,10 +135,10 @@ func (s3a *S3ApiServer) exists(parentDirectoryPath string, entryName string, isD
|
|||
Name: entryName,
|
||||
}
|
||||
|
||||
glog.V(1).Infof("delete entry %v/%v: %v", parentDirectoryPath, entryName, request)
|
||||
glog.V(1).Infof("exists entry %v/%v: %v", parentDirectoryPath, entryName, request)
|
||||
resp, err := client.LookupDirectoryEntry(ctx, request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("delete entry %s/%s: %v", parentDirectoryPath, entryName, err)
|
||||
return fmt.Errorf("exists entry %s/%s: %v", parentDirectoryPath, entryName, err)
|
||||
}
|
||||
|
||||
exists = resp.Entry.IsDirectory == isDirectory
|
||||
|
|
|
@ -21,7 +21,7 @@ func (s3a *S3ApiServer) ListBucketsHandler(w http.ResponseWriter, r *http.Reques
|
|||
|
||||
var response ListAllMyBucketsResponse
|
||||
|
||||
entries, err := s3a.list(s3a.option.BucketsPath)
|
||||
entries, err := s3a.list(s3a.option.BucketsPath, "", "", false, 0)
|
||||
|
||||
if err != nil {
|
||||
writeErrorResponse(w, ErrInternalError, r.URL)
|
||||
|
|
|
@ -143,6 +143,8 @@ func (s3a *S3ApiServer) ListMultipartUploadsHandler(w http.ResponseWriter, r *ht
|
|||
return
|
||||
}
|
||||
|
||||
// TODO handle encodingType
|
||||
|
||||
writeSuccessResponseXML(w, encodeResponse(response))
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"github.com/chrislusf/seaweedfs/weed/filer2"
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/chrislusf/seaweedfs/weed/filer2"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -126,7 +126,7 @@ func (s3a *S3ApiServer) listFilerEntries(bucket, originalPrefix string, maxKeys
|
|||
contents = append(contents, &s3.Object{
|
||||
Key: aws.String(fmt.Sprintf("%s%s", dir, entry.Name)),
|
||||
LastModified: aws.Time(time.Unix(entry.Attributes.Mtime, 0)),
|
||||
ETag: aws.String("\"2345sgfwetrewrt\""), // TODO add etag
|
||||
ETag: aws.String("\"" + filer2.ETag(entry.Chunks) + "\""),
|
||||
Size: aws.Int64(int64(filer2.TotalSize(entry.Chunks))),
|
||||
Owner: &s3.Owner{
|
||||
ID: aws.String("bcaf161ca5fb16fd081034f"),
|
||||
|
|
|
@ -119,6 +119,7 @@ func (fs *FilerServer) handleMultipleChunks(w http.ResponseWriter, r *http.Reque
|
|||
if mimeType != "" {
|
||||
w.Header().Set("Content-Type", mimeType)
|
||||
}
|
||||
setEtag(w, filer2.ETag(entry.Chunks))
|
||||
|
||||
totalSize := int64(filer2.TotalSize(entry.Chunks))
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
etag := resp.Header.Get("ETag")
|
||||
resp_body, ra_err := ioutil.ReadAll(resp.Body)
|
||||
if ra_err != nil {
|
||||
glog.V(0).Infoln("failing to upload to volume server", r.RequestURI, ra_err.Error())
|
||||
|
@ -202,6 +203,7 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||
FileId: fileId,
|
||||
Size: uint64(ret.Size),
|
||||
Mtime: time.Now().UnixNano(),
|
||||
ETag: etag,
|
||||
}},
|
||||
}
|
||||
if db_err := fs.filer.CreateEntry(entry); db_err != nil {
|
||||
|
|
|
@ -88,12 +88,11 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
}
|
||||
}
|
||||
etag := n.Etag()
|
||||
if inm := r.Header.Get("If-None-Match"); inm == etag {
|
||||
if inm := r.Header.Get("If-None-Match"); inm == "\""+n.Etag()+"\"" {
|
||||
w.WriteHeader(http.StatusNotModified)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Etag", etag)
|
||||
setEtag(w, n.Etag())
|
||||
|
||||
if n.HasPairs() {
|
||||
pairMap := make(map[string]string)
|
||||
|
|
|
@ -44,8 +44,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||
ret.Name = string(needle.Name)
|
||||
}
|
||||
ret.Size = size
|
||||
etag := needle.Etag()
|
||||
w.Header().Set("Etag", etag)
|
||||
setEtag(w, needle.Etag())
|
||||
writeJsonQuiet(w, r, httpStatus, ret)
|
||||
}
|
||||
|
||||
|
@ -173,3 +172,9 @@ func (vs *VolumeServer) batchDeleteHandler(w http.ResponseWriter, r *http.Reques
|
|||
|
||||
writeJsonQuiet(w, r, http.StatusAccepted, ret)
|
||||
}
|
||||
|
||||
func setEtag(w http.ResponseWriter, etag string) {
|
||||
if etag != "" {
|
||||
w.Header().Set("ETag", "\""+etag+"\"")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,5 +26,5 @@ func (c CRC) Value() uint32 {
|
|||
func (n *Needle) Etag() string {
|
||||
bits := make([]byte, 4)
|
||||
util.Uint32toBytes(bits, uint32(n.Checksum))
|
||||
return fmt.Sprintf("\"%x\"", bits)
|
||||
return fmt.Sprintf("%x", bits)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue