-
Notifications
You must be signed in to change notification settings - Fork 8
/
copy.go
59 lines (50 loc) · 1.49 KB
/
copy.go
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
// Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.
package main
// #include "uplink_definitions.h"
import "C"
// uplink_copy_object copies object to a same/different bucket and key.
//
//export uplink_copy_object
func uplink_copy_object(project *C.UplinkProject, old_bucket_name, old_object_key, new_bucket_name, new_object_key *C.uplink_const_char,
options *C.UplinkCopyObjectOptions) C.UplinkObjectResult { //nolint:golint
if project == nil {
return C.UplinkObjectResult{
error: mallocError(ErrInvalidHandle.New("project")),
}
}
if old_bucket_name == nil {
return C.UplinkObjectResult{
error: mallocError(ErrInvalidHandle.New("old_bucket_name")),
}
}
if old_object_key == nil {
return C.UplinkObjectResult{
error: mallocError(ErrInvalidHandle.New("old_object_key")),
}
}
if new_bucket_name == nil {
return C.UplinkObjectResult{
error: mallocError(ErrInvalidHandle.New("new_bucket_name")),
}
}
if new_object_key == nil {
return C.UplinkObjectResult{
error: mallocError(ErrInvalidHandle.New("new_object_key")),
}
}
proj, ok := universe.Get(project._handle).(*Project)
if !ok {
return C.UplinkObjectResult{
error: mallocError(ErrInvalidHandle.New("project")),
}
}
object, err := proj.CopyObject(proj.scope.ctx,
C.GoString(old_bucket_name), C.GoString(old_object_key),
C.GoString(new_bucket_name), C.GoString(new_object_key),
nil)
return C.UplinkObjectResult{
error: mallocError(err),
object: mallocObject(object),
}
}