Esempio n. 1
0
        /// <summary>
        /// Get a list of files ordered by name (structure ResInfo._Embedded), a flat list of all files in the Drive in alphabetical order.
        /// </summary>
        /// <param name="limit">Maximum number of output resources, default 20</param>
        /// <param name="media_type">An array of file types to include in the list. Example 'new Media_type [] {Media_type.Unknown, Media_type.Text}'</param>
        /// <param name="sort">A field for sorting the nested resources. Example 'SortField.Size' sort by file size</param>
        /// <param name="fields">An array of return fields. Example 'new ResFields [] {ResFields.Name, ResFields.Type, ResFields.Size}'</param>
        /// <param name="offset">Offset from the beginning of the list of nested resources.</param>
        /// <param name="preview_crop">Allow trimming the preview.</param>
        /// <param name="preview_size">The size of the preview. Example "120x240"</param>
        /// <returns>The return value of the ResInfo._Embedded structure</returns>
        public ResInfo GetResourceByName(int?limit  = null, Media_type[] media_type = null, SortField?sort      = null, ResFields[] fields = null,
                                         int?offset = null, bool?preview_crop       = null, string preview_size = null)
        {
            string  content;
            ResInfo resInfo = new ResInfo();
            Param   param   = new Param();

            if (media_type != null)
            {
                foreach (Media_type i in media_type)
                {
                    param.Media_type += i + ",";
                }
                param.Media_type = param.Media_type.Remove(param.Media_type.Length - 1);
            }

            param.Limit = limit;

            if (sort != null)
            {
                param.Sort = Enum.GetName(typeof(SortField), sort);
            }

            if (fields != null)
            {
                foreach (ResFields i in fields)
                {
                    if (i != ResFields._Embedded)
                    {
                        param.Fields += "items." + i + ",";
                    }
                }
                param.Fields = param.Fields.Remove(param.Fields.Length - 1);
            }

            param.Offset       = offset;
            param.Preview_crop = preview_crop;
            param.Preview_size = preview_size;

            content = CommandDisk(Oauth, YandexDiskAsk.Get_list_files_order_by_name, param);

            if (content != null)
            {
                resInfo = ResInfo.GetResInfo(content, true);
            }

            return(resInfo);
        }
Esempio n. 2
0
        /// <summary>
        /// Get meta information about file or folder, dy default get meta information root disk
        /// </summary>
        /// <param name="limit">Maximum number of output resources, default 20</param>
        /// <param name="path">Path to resource. Required value in Url - format. Example 'old/new/good.txt'</param>
        /// <param name="sort">A field for sorting the nested resources. The example 'SortField.Created' is sorted by the date of creation of the resource</param>
        /// <param name="fields">An array of return fields. Example 'new ResFields [] {ResFields.Name, ResFields.Type, ResFields.Size}'</param>
        /// <param name="offset">Offset from the beginning of the list of nested resources.</param>
        /// <param name="preview_crop">Allow trimming the preview.</param>
        /// <param name="preview_size">The size of the preview. Example "120x240"</param>
        /// <returns>The return value of the ResInfo structure</returns>
        public ResInfo GetResInfo(int?limit  = null, string path       = null, SortField?sort      = null, ResFields[] fields = null,
                                  int?offset = null, bool?preview_crop = null, string preview_size = null)
        {
            string  content;
            ResInfo resInfo = new ResInfo();
            Param   param   = new Param();

            param.Path  = path;
            param.Limit = limit;

            if (sort != null)
            {
                param.Sort = Enum.GetName(typeof(SortField), sort);
            }

            if (fields != null)
            {
                foreach (ResFields i in fields)
                {
                    if (i != ResFields._Embedded)
                    {
                        param.Fields += i + "," + "_embedded.items." + i + ",";
                    }
                }
                param.Fields = param.Fields.Remove(param.Fields.Length - 1);
            }

            param.Offset       = offset;
            param.Preview_crop = preview_crop;
            param.Preview_size = preview_size;

            content = CommandDisk(Oauth, YandexDiskAsk.Get_meta_information_about_file_or_folder, param);

            if (content != null)
            {
                resInfo = ResInfo.GetResInfo(content);
            }

            return(resInfo);
        }
Esempio n. 3
0
        /// <summary>
        /// Get the list of published resources (structure ResInfo._Embedded), a flat list of all the list of published resources in the User's disk.
        /// </summary>
        /// <param name="limit">Maximum number of output resources, default 20</param>
        /// <param name="type">The type of resource to include in the list. Example 'TypeRes.Dir', folders only</param>
        /// <param name="fields">An array of return fields. Example 'new ResFields [] {ResFields.Name, ResFields.Type, ResFields.Size}'</param>
        /// <param name="offset">Offset from the beginning of the list of nested resources.</param>
        /// <param name="preview_crop">Allow trimming the preview.</param>
        /// <param name="preview_size">The size of the preview. Example "120x240"</param>
        /// <returns>The return value of the ResInfo._Embedded structure</returns>
        public ResInfo GetResourcePublic(int?limit = null, TypeRes?type = null, ResFields[] fields = null, int?offset = null, bool?preview_crop = null, string preview_size = null)
        {
            string  content;
            ResInfo resInfo = new ResInfo();
            Param   param   = new Param();

            if (type != null)
            {
                param.Type = Enum.GetName(typeof(TypeRes), type);
            }

            param.Limit = limit;

            if (fields != null)
            {
                foreach (ResFields i in fields)
                {
                    if (i != ResFields._Embedded)
                    {
                        param.Fields += "items." + i + ",";
                    }
                }
                param.Fields = param.Fields.Remove(param.Fields.Length - 1);
            }

            param.Offset       = offset;
            param.Preview_crop = preview_crop;
            param.Preview_size = preview_size;

            content = CommandDisk(Oauth, YandexDiskAsk.Get_list_public_resources, param);

            if (content != null)
            {
                resInfo = ResInfo.GetResInfo(content, true);
            }

            return(resInfo);
        }