share.shareFile.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. var shareUUID = share.shareFile("user:/Desktop/test.pptx", 10);
  8. console.log(shareUUID);
  9. if (shareUUID == null){
  10. //Share error
  11. sendResp("Share failed");
  12. }else{
  13. //Share success.
  14. //Check if share UUID exists
  15. console.log("Share UUID is valid: " + share.checkShareExists(shareUUID));
  16. //Check if the source file is shared
  17. console.log("Source file is shared: " + share.fileIsShared("user:/Desktop/test.pptx"));
  18. console.log("Source file share permission: " + share.checkSharePermission(shareUUID));
  19. //Remove the share using UUID
  20. //share.removeShare(shareUUID);
  21. //Delay 11 seconds
  22. delay(11000)
  23. //Check is the share is still valid
  24. console.log("Share UUID valid after share expired: " + share.checkShareExists(shareUUID));
  25. //Return the share UUID
  26. sendResp("OK");
  27. }
  28. }
  29. main();