@@ -331,6 +331,9 @@ func (d *Streamtape) Put(ctx context.Context, dstDir model.Obj, file model.FileS
331331 if folderID != "" && folderID != "0" {
332332 params ["folder" ] = folderID
333333 }
334+ if d .Sha256 != "" {
335+ params ["sha256" ] = d .Sha256
336+ }
334337
335338 var uploadURL uploadURLResult
336339 if err := d .callAPI (ctx , "/file/ul" , params , & uploadURL ); err != nil {
@@ -381,6 +384,35 @@ func (d *Streamtape) Put(ctx context.Context, dstDir model.Obj, file model.FileS
381384 }, nil
382385}
383386
387+ // PutURL initiates a remote upload from an external URL
388+ func (d * Streamtape ) PutURL (ctx context.Context , dstDir model.Obj , name , url string ) (model.Obj , error ) {
389+ folderID := d .RootFolderID
390+ if dstDir .GetID () != "" {
391+ folderID = folderIDFromObjID (dstDir .GetID ())
392+ }
393+
394+ params := map [string ]string {
395+ "url" : url ,
396+ }
397+ if folderID != "" && folderID != "0" {
398+ params ["folder" ] = folderID
399+ }
400+ if name != "" {
401+ params ["name" ] = name
402+ }
403+
404+ var result remoteDlAddResult
405+ if err := d .callAPI (ctx , "/remotedl/add" , params , & result ); err != nil {
406+ return nil , err
407+ }
408+
409+ return & model.Object {
410+ ID : encodeRemoteUploadID (result .ID ),
411+ Name : name ,
412+ IsFolder : false ,
413+ }, nil
414+ }
415+
384416func (d * Streamtape ) GetArchiveMeta (ctx context.Context , obj model.Obj , args model.ArchiveArgs ) (model.ArchiveMeta , error ) {
385417 return nil , errs .NotImplement
386418}
@@ -397,4 +429,115 @@ func (d *Streamtape) ArchiveDecompress(ctx context.Context, srcObj, dstDir model
397429 return nil , errs .NotImplement
398430}
399431
432+ func (d * Streamtape ) Other (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
433+ switch strings .ToLower (args .Method ) {
434+ case "remotedl_status" :
435+ return d .remoteDlStatus (ctx , args )
436+ case "remotedl_remove" :
437+ return d .remoteDlRemove (ctx , args )
438+ case "file_info" :
439+ return d .fileInfo (ctx , args )
440+ case "thumbnail" :
441+ return d .thumbnail (ctx , args )
442+ case "conversion_status" :
443+ return d .conversionStatus (ctx , args )
444+ default :
445+ return nil , errs .NotSupport
446+ }
447+ }
448+
449+ func (d * Streamtape ) extractRemoteUploadID (args model.OtherArgs ) (string , error ) {
450+ uploadID := remoteUploadIDFromObjID (args .Obj .GetID ())
451+ if uploadID == "" {
452+ if data , ok := args .Data .(map [string ]interface {}); ok {
453+ if id , ok := data ["id" ].(string ); ok {
454+ uploadID = id
455+ }
456+ }
457+ }
458+ if uploadID == "" {
459+ return "" , fmt .Errorf ("remote upload ID required" )
460+ }
461+ return uploadID , nil
462+ }
463+
464+ func (d * Streamtape ) remoteDlStatus (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
465+ uploadID , err := d .extractRemoteUploadID (args )
466+ if err != nil {
467+ return nil , err
468+ }
469+
470+ var result remoteDlStatusResult
471+ if err := d .callAPI (ctx , "/remotedl/status" , map [string ]string {"id" : uploadID }, & result ); err != nil {
472+ return nil , err
473+ }
474+ return result , nil
475+ }
476+
477+ func (d * Streamtape ) remoteDlRemove (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
478+ uploadID , err := d .extractRemoteUploadID (args )
479+ if err != nil {
480+ return nil , err
481+ }
482+
483+ if err := d .callAPI (ctx , "/remotedl/remove" , map [string ]string {"id" : uploadID }, nil ); err != nil {
484+ return nil , err
485+ }
486+ return true , nil
487+ }
488+
489+ func (d * Streamtape ) fileInfo (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
490+ var fileIDs string
491+ if data , ok := args .Data .(map [string ]interface {}); ok {
492+ if ids , ok := data ["file_ids" ].(string ); ok {
493+ fileIDs = ids
494+ }
495+ }
496+ if fileIDs == "" {
497+ fileIDs = fileIDFromObjID (args .Obj .GetID ())
498+ }
499+ if fileIDs == "" {
500+ return nil , fmt .Errorf ("file IDs required" )
501+ }
502+
503+ var result fileInfoResult
504+ if err := d .callAPI (ctx , "/file/info" , map [string ]string {"file" : fileIDs }, & result ); err != nil {
505+ return nil , err
506+ }
507+ return result , nil
508+ }
509+
510+ func (d * Streamtape ) thumbnail (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
511+ fileID := fileIDFromObjID (args .Obj .GetID ())
512+ if fileID == "" {
513+ return nil , fmt .Errorf ("file ID required" )
514+ }
515+
516+ var result string
517+ if err := d .callAPI (ctx , "/file/getsplash" , map [string ]string {"file" : fileID }, & result ); err != nil {
518+ return nil , err
519+ }
520+ return result , nil
521+ }
522+
523+ func (d * Streamtape ) conversionStatus (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
524+ isFailed := false
525+ if data , ok := args .Data .(map [string ]interface {}); ok {
526+ if t , ok := data ["type" ].(string ); ok && t == "failed" {
527+ isFailed = true
528+ }
529+ }
530+
531+ endpoint := "/file/runningconverts"
532+ if isFailed {
533+ endpoint = "/file/failedconverts"
534+ }
535+
536+ var result conversionResult
537+ if err := d .callAPI (ctx , endpoint , nil , & result ); err != nil {
538+ return nil , err
539+ }
540+ return result , nil
541+ }
542+
400543var _ driver.Driver = (* Streamtape )(nil )
0 commit comments