Пример #1
0
        /// <summary>
        /// Locate the Camera Uploads folder node to use as parent for the uploads
        /// </summary>
        /// <returns>Camera Uploads root folder node</returns>
        public static async Task <MNode> GetCameraUploadRootNodeAsync()
        {
            // First try to retrieve the Cloud Drive root node
            var rootNode = MegaSdk.getRootNode();

            if (rootNode == null)
            {
                return(null);
            }

            // Locate the camera upload node
            var cameraUploadNode = FindCameraUploadNode(rootNode);

            // If node found, return the node
            if (cameraUploadNode != null)
            {
                return(cameraUploadNode);
            }

            // If node not found, create a new Camera Uploads node
            var folder = new MegaRequestListener <bool>();
            var result = await folder.ExecuteAsync(() => MegaSdk.createFolder("Camera Uploads", rootNode, folder));

            return(result ? FindCameraUploadNode(rootNode) : null);
        }
Пример #2
0
        /// <summary>
        /// Fastlogin to MEGA user account
        /// </summary>
        /// <returns>True if succeeded, else false</returns>
        private static async Task <bool> LoginAsync()
        {
            try
            {
                // Try to load shared session token
                var sessionToken = await SettingsService.LoadSessionFromLockerAsync();

                if (string.IsNullOrEmpty(sessionToken) || string.IsNullOrWhiteSpace(sessionToken))
                {
                    throw new Exception("Session token is empty.");
                }

                var login = new MegaRequestListener <bool>();
                return(await login.ExecuteAsync(() => SdkService.MegaSdk.fastLogin(sessionToken, login)));
            }
            catch (Exception e)
            {
                LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Error logging in", e);
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// Fetch the nodes from MEGA
        /// </summary>
        /// <returns>True if succeeded, else False</returns>
        private static async Task <bool> FetchNodesAsync()
        {
            var fetch = new MegaRequestListener <bool>();

            return(await fetch.ExecuteAsync(() => SdkService.MegaSdk.fetchNodes(fetch)));
        }