share.shareFile.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //File Share API
  2. //This script demonstrate how to share a file on ArozOS using AGI script
  3. //Require the share lib
  4. requirelib("share");
  5. function main(){
  6. //Share the file for 10 seconds
  7. //Unset the second variable or set to 0 for no expire time
  8. var shareUUID = share.shareFile("user:/Desktop/test.pptx", 10);
  9. console.log(shareUUID);
  10. if (shareUUID == null){
  11. //Share error
  12. sendResp("Share failed");
  13. }else{
  14. //Share success.
  15. //Check if share UUID exists
  16. console.log("Share UUID is valid: " + share.checkShareExists(shareUUID));
  17. //Check if the source file is shared
  18. console.log("Source file is shared: " + share.fileIsShared("user:/Desktop/test.pptx"));
  19. console.log("Source file share permission: " + share.checkSharePermission(shareUUID));
  20. //Remove the share using UUID
  21. //share.removeShare(shareUUID);
  22. //Delay 11 seconds
  23. delay(11000)
  24. //Check is the share is still valid
  25. console.log("Share UUID valid after share expired: " + share.checkShareExists(shareUUID));
  26. //Return the share UUID
  27. sendResp("OK");
  28. }
  29. }
  30. main();