TagLib-sharp: Reading metadata from HttpPostedFile object

谁都会走 提交于 2019-12-05 06:16:55

You would want to do something as follows. The caveat is that the steam has to be seekable an I do not know if HttpPostedFile.InputStream is.

TagLib.File myFile = TagLib.File.Create(new HttpPostedFileAbstraction(postedFile));

public class HttpPostedFileAbstraction : TagLib.File.IFileAbstraction
{
    private HttpPostedFile file;

    public HttpPostedFileAbstraction(HttpPostedFile file)
    {
        this.file = file;
    }

    public string Name {
        get { return file.FileName; }
    }

    public System.IO.Stream ReadStream {
        get { return file.InputStream; }
    }

    public System.IO.Stream WriteStream {
        get { throw new Exception("Cannot write to HttpPostedFile"); }
    }

    public void CloseStream (System.IO.Stream stream) { }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!