Ejemplo n.º 1
0
        internal List <FB_File> get_files_from_paths(Dictionary <string, Stream> file_paths)
        {
            var files = new List <FB_File>();

            foreach (var file_path in file_paths)
            {
                var file = new FB_File();
                file.data     = file_path.Value;
                file.path     = Path.GetFileName(file_path.Key);
                file.mimetype = MimeMapping.MimeUtility.GetMimeMapping(file.path);
                files.Add(file);
            }
            return(files);
        }
Ejemplo n.º 2
0
        internal async Task <List <FB_File> > get_files_from_urls(ISet <string> file_urls)
        {
            var files = new List <FB_File>();

            foreach (var file_url in file_urls)
            {
                var r = await this._cleanGet <string>(file_url);

                // We could possibly use r.headers.get('Content-Disposition'), see
                // https://stackoverflow.com/a/37060758
                var file = new FB_File();
                file.data = await r.Content.ReadAsStreamAsync();

                file.path     = Utils.GetFileNameFromUrl(file_url);
                file.mimetype = r.Content.Headers.ContentType.MediaType;
                files.Add(file);
            }
            return(files);
        }