/// <summary> /// Initializes a new instance of the <see cref="RawReader"/> class. /// </summary> /// <param name="input">The input.</param> /// <param name="strictDecoding">if set to <c>true</c> [strict decoding].</param> public RawReader(Stream input, bool strictDecoding) { input.CannotBeNull(); this.input = input; this.peeked = new byte[1]; this.strictDecoding = strictDecoding; }
/// <summary> /// Decoded the stream into a BEncoded value. /// </summary> /// <param name="stream">The stream containing the BEncoded data</param> /// <returns>The BEncoded value.</returns> public static BEncodedValue Decode(Stream stream) { stream.CannotBeNull(); return(Decode(new RawReader(stream))); }
/// <summary> /// Decodes the specified stream. /// </summary> /// <typeparam name="T">The BEncoded value type.</typeparam> /// <param name="stream">The stream.</param> /// <returns> /// The BEncoded value. /// </returns> public static T Decode <T>(Stream stream) where T : BEncodedValue { stream.CannotBeNull(); return((T)BEncodedValue.Decode(stream)); }
/// <summary> /// Decodes the torrent. /// </summary> /// <param name="stream">The stream.</param> /// <value>The BEncoded dictionary.</value> public static BEncodedDictionary DecodeTorrent(Stream stream) { stream.CannotBeNull(); return(DecodeTorrent(new RawReader(stream))); }
public int UploadFileInTempFolder(Stream file, string fileName, string contentType, int contentLenght,string parentFolder = null) { parentFolder.CannotBeNull("userId"); fileName.CannotBeNull("filename"); file.CannotBeNull("file"); UploadFileInFolder(file, fileName, contentType, contentLenght, true, parentFolder); var newId = _fileRepository.InsertTempUpload(parentFolder, fileName,contentType,contentLenght); return newId; }
public void UploadFileInFolder(Stream file, string fileName, string contentType, int contentLenght,bool isTmpFolder = false,string parentFolder =null) { file.CannotBeNull("file"); fileName.CannotBeNull("fileName"); string defaultFolfer = isTmpFolder ? Config.UploadsTempFolder : Config.UploadsFolder; var path = Path.IsPathRooted(defaultFolfer)? defaultFolfer: Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, defaultFolfer)); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var dir = new DirectoryInfo(path); if (!string.IsNullOrEmpty(parentFolder)) { path= dir.CreateSubdirectory(parentFolder).FullName; } var buffer = new byte[contentLenght]; file.Read(buffer,0,contentLenght); var fileNameFull = Path.Combine(path, fileName); using (var fileStream = new FileStream(fileNameFull, FileMode.Create)) { fileStream.Write(buffer,0,contentLenght); } var versions = Config.UploadThumbSettings; if (IsFileImage(fileName)) FileSystem.ResizeImage(fileNameFull, path, versions); }