@@ -24,10 +24,11 @@ import (
24
24
"net/http"
25
25
"path"
26
26
27
+ apppb "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1"
27
28
appregistry "github.com/cs3org/go-cs3apis/cs3/app/registry/v1beta1"
28
29
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
29
30
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
30
- provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
31
+ storagepb "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
31
32
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
32
33
"github.com/cs3org/reva/internal/http/services/datagateway"
33
34
"github.com/cs3org/reva/pkg/appctx"
@@ -158,8 +159,8 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
158
159
return
159
160
}
160
161
161
- statParentContainerReq := & provider .StatRequest {
162
- Ref : & provider .Reference {
162
+ statParentContainerReq := & storagepb .StatRequest {
163
+ Ref : & storagepb .Reference {
163
164
ResourceId : parentContainerRef ,
164
165
},
165
166
}
@@ -174,16 +175,16 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
174
175
return
175
176
}
176
177
177
- if parentContainer .Info .Type != provider .ResourceType_RESOURCE_TYPE_CONTAINER {
178
+ if parentContainer .Info .Type != storagepb .ResourceType_RESOURCE_TYPE_CONTAINER {
178
179
writeError (w , r , appErrorInvalidParameter , "the parent container id does not point to a container" , nil )
179
180
return
180
181
}
181
182
182
- fileRef := & provider .Reference {
183
+ fileRef := & storagepb .Reference {
183
184
Path : path .Join (parentContainer .Info .Path , utils .MakeRelativePath (filename )),
184
185
}
185
186
186
- statFileReq := & provider .StatRequest {
187
+ statFileReq := & storagepb .StatRequest {
187
188
Ref : fileRef ,
188
189
}
189
190
statFileRes , err := client .Stat (ctx , statFileReq )
@@ -202,7 +203,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
202
203
}
203
204
204
205
// Create empty file via storageprovider
205
- createReq := & provider .InitiateFileUploadRequest {
206
+ createReq := & storagepb .InitiateFileUploadRequest {
206
207
Ref : fileRef ,
207
208
Opaque : & typespb.Opaque {
208
209
Map : map [string ]* typespb.OpaqueEntry {
@@ -269,7 +270,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
269
270
return
270
271
}
271
272
272
- if statRes .Info .Type != provider .ResourceType_RESOURCE_TYPE_FILE {
273
+ if statRes .Info .Type != storagepb .ResourceType_RESOURCE_TYPE_FILE {
273
274
writeError (w , r , appErrorInvalidParameter , "the given file id does not point to a file" , nil )
274
275
return
275
276
}
@@ -339,7 +340,7 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) {
339
340
340
341
fileID := r .Form .Get ("file_id" )
341
342
342
- var fileRef provider .Reference
343
+ var fileRef storagepb .Reference
343
344
if fileID == "" {
344
345
path := r .Form .Get ("path" )
345
346
if path == "" {
@@ -356,7 +357,7 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) {
356
357
fileRef .ResourceId = resourceID
357
358
}
358
359
359
- statRes , err := client .Stat (ctx , & provider .StatRequest {Ref : & fileRef })
360
+ statRes , err := client .Stat (ctx , & storagepb .StatRequest {Ref : & fileRef })
360
361
if err != nil {
361
362
writeError (w , r , appErrorServerError , "Internal error accessing the file, please try again later" , err )
362
363
return
@@ -370,7 +371,7 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) {
370
371
return
371
372
}
372
373
373
- if statRes .Info .Type != provider .ResourceType_RESOURCE_TYPE_FILE {
374
+ if statRes .Info .Type != storagepb .ResourceType_RESOURCE_TYPE_FILE {
374
375
writeError (w , r , appErrorInvalidParameter , "the given file id does not point to a file" , nil )
375
376
return
376
377
}
@@ -417,7 +418,16 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) {
417
418
return
418
419
}
419
420
420
- js , err := json .Marshal (openRes .AppUrl )
421
+ // recreate the structure to be able to marshal the AppUrl.Target as a string
422
+ js , err := json .Marshal (
423
+ map [string ]interface {}{
424
+ "app_url" : openRes .AppUrl .AppUrl ,
425
+ "method" : openRes .AppUrl .Method ,
426
+ "form_parameters" : openRes .AppUrl .FormParameters ,
427
+ "headers" : openRes .AppUrl .Headers ,
428
+ "target" : appTargetToString (openRes .AppUrl .Target ),
429
+ },
430
+ )
421
431
if err != nil {
422
432
writeError (w , r , appErrorServerError , "Internal error with JSON payload" ,
423
433
errors .Wrap (err , "error marshalling JSON response" ))
@@ -442,7 +452,7 @@ func (s *svc) handleNotify(w http.ResponseWriter, r *http.Request) {
442
452
}
443
453
444
454
fileID := r .Form .Get ("file_id" )
445
- var fileRef provider .Reference
455
+ var fileRef storagepb .Reference
446
456
if fileID == "" {
447
457
path := r .Form .Get ("path" )
448
458
if path == "" {
@@ -488,7 +498,7 @@ func filterAppsByUserAgent(mimeTypes []*appregistry.MimeTypeInfo, userAgent stri
488
498
return res
489
499
}
490
500
491
- func resolveViewMode (res * provider .ResourceInfo , vm string ) gateway.OpenInAppRequest_ViewMode {
501
+ func resolveViewMode (res * storagepb .ResourceInfo , vm string ) gateway.OpenInAppRequest_ViewMode {
492
502
var viewMode gateway.OpenInAppRequest_ViewMode
493
503
if vm != "" {
494
504
viewMode = utils .GetViewMode (vm )
@@ -512,3 +522,14 @@ func resolveViewMode(res *provider.ResourceInfo, vm string) gateway.OpenInAppReq
512
522
}
513
523
return viewMode
514
524
}
525
+
526
+ func appTargetToString (t apppb.Target ) string {
527
+ switch t {
528
+ case apppb .Target_TARGET_IFRAME :
529
+ return "iframe"
530
+ case apppb .Target_TARGET_BLANK :
531
+ return "blank"
532
+ default :
533
+ return "iframe"
534
+ }
535
+ }
0 commit comments