share.shareFile.js 1012 B

123456789101112131415161718192021222324252627282930313233343536
  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. //Remove the share using UUID
  19. //share.removeShare(shareUUID);
  20. //Delay 11 seconds
  21. delay(11000)
  22. //Check is the share is still valid
  23. console.log("Share UUID valid after share expired: " + share.checkShareExists(shareUUID));
  24. //Return the share UUID
  25. sendResp("OK");
  26. }
  27. }
  28. main();