I did read the following posts:
Pause/Resume Upload in C#
resume uploads using HTTP?
But didn't got a perfect solution to my problem.
In the above posts, one of the answers says "client and server needs to identify the file some how i suggest the use of a Guid so the server knows what file to append the extra data too." Request you to plz visit the first link of the aobve and find that answer. This answer is all about streaming. Can someone plz provide links using which I can build such kind of code?
In these posts one of the answer said "you can send several small file pieces and rebuild them server side"...HOW?
Can't I use something like checksum etc to detect how much part is uploaded and how much more needs to be and append it to that file? If yes, how?
Streams are a fairly fundemental concept in working with files on the .NET platform (as it is in Java, C and other languages). You should start by reading about them and how to use them. See the Stream class on MSDN.
HOW? By using streaming - you stream parts of the file, in small chunks (using an offset into the file and the size of chunk). Again, see Stream documentation.
You could, but checksums of different files may be the same - with a GUID the chance of a collision is pretty small compared to checksums.
Related
My application currently allows direct links to PDF files on the server, but the files now need to be secured and direct links will have to be phased out because of security concerns.
I have tried the following lines to send PDF file to the client. It works fine.
Response.Clear();
Response.ContentType = "Application/pdf";
Response.WriteFile(filepath);
Response.End();
But there is a catch.
When a PDF file is linked, the browser renders the first few pages right away while downloading the rest. But with the approach above, the browser waits until the entire file has been downloaded and then proceeds to render the PDF.
So is there a way to trick the browser into mimicking opening a directly linked PDF?
After reading your post I realized my application had the same behavior (although given the typical sizes of files and the formats used it hasn't been an issue - at least not yet...) Upon some research, you'll have to choose from a couple of options depending upon how much complexity you want to introduce:
If you want a simpler implementation, you'll need to change your approach a bit to set up a loop that reads a certain amount of the file into a buffer in memory and then performs a Response.Write for that buffer. In the loop you'd then do a Response.Flush to push that data towards the client. Since this is synchronous, you'll have to wait until the flush is complete before you can push down the next block of the file. But, if the primary goal is getting the first couple of blocks out there so they client application can begin working with them, this might meet your needs.
If you want potentially better server-side scalability and are willing to accept a bit more complexity, you'll need to explore using Response.BeginFlush. I believe asynchronous writing was introduced in .Net 4.5. Here's a link that should get you started:
http://www.slideshare.net/pragyanshis/asynchronous-reading-and-writing-http-r-equest
I'm adding exploring both approaches to my "to do" list for my own application...
I have just started looking at some work related with reading a mpeg-ts file. This is my first project with video streaming and my first task is to read the program names from the file.
I am currently looking at FFMpeg and FFProbe and have experience in C# and wanted to know which tool/language I should use to do this?
Or do I need another tool or language?
I have launched TSReader and I can see the PAT section which contains the information.
I've had good luck with NetBeans Java IDE and the ProjectX source code. since ProjectX is designed to transform different formats, it tends to have a lot of descriptive info about the file available on the UI and relatively easy to figure out variable naming in the code as well.
Contrast with other programs, which may be more mysterious in their decoding of the format, because they don't ever display the raw header info and don't have those variables named so clearly in code.
Hi i'm new programming and i have written few application to access pdf content by using some dll files, but now my question is how can we write our own dll to access the pdf files. I know it's a big process but i'm very much interested to learn about this. any one please help me.
You can start by reading the PDF specification (warning 32MB behind this link) in order to understand how the PDF file format is implemented. This is necessary if you want to be able to parse it and extract the information you are interested in.
In the meantime (as this reading might occupy you during a certain amount of time) if you have pressing project deadlines you probably want to use an existing library such as iTextSharp.
I know it's a big process but i'm very much interested to learn about this.
That's true. I'd like to suggest to study some open source APIs (iTextSharp) and PDF SDK.
I have an old PC on which i have a large pst file , and i have the idea to write a small C# program to spilt it into smaller files so that i can better manage them if needed ( i know that sounds weird and that there are also available tools in google but i thought it will be fun to play with it ).The problem is that i can't find good article or API info which functions are best suited ( if there are any at all ) for managing those files , Ideas ?
Thanks in advance
Take a look at Redemption API. This API does not require Outlook to be installed (only stand-alone MAPI) and does not require outlook to run.
First just a clarification by PST file you mean you outlook information?
Running on that I know of no API to manipulate it but you can get the documentation for it at http://msdn.microsoft.com/en-us/library/ff385210(v=office.12).aspx this is a large and complex specification for a binary format. Always play with a copy of it not the real thing.
One approach that might be better is using the ActiveX/COM interface provided by outlook to interact with this file abstractly, so instead of dealing with the physical layout of the file work with contacts, folder and email messages.
It may be worth your while finding out how open source mail clients (Like thunderbird) import from outlook. You may be able to pull there code out into an API, as long as you follow the licence conditions.
Not the easier answer, but it is the one I have.
I have a table with a binary column which stores files of a number of different possible filetypes (PDF, BMP, JPEG, WAV, MP3, DOC, MPEG, AVI etc.), but no columns that store either the name or the type of the original file. Is there any easy way for me to process these rows and determine the type of each file stored in the binary column? Preferably it would be a utility that only reads the file headers, so that I don't have to fully extract each file to determine its type.
Clarification: I know that the approach here involves reading just the beginning of each file. I'm looking for a good resource (aka links) that can do this for me without too much fuss. Thanks.
Also, just C#/.NET on Windows, please. I'm not using Linux and can't use Cygwin (doesn't work on Windows CE, among other reasons).
you can use these tools to find the file format.
File Analyser
http://www.softpedia.com/get/Programming/Other-Programming-Files/File-Analyzer.shtml
What Format
http://www.jozy.nl/whatfmt.html
PE file format analyser
http://peid.has.it/
This website may be helpful for you.
http://mark0.net/onlinetrid.aspx
Note:
i have included the download links to make sure that you are getting the right tool name and information.
please verify the source before you download them.
i have used a tool in the past i think it is File Analyser, which will tell you the closest match.
happy tooling.
This is not a complete answer, but a place to start would be a "magic numbers" library. This examines the first few bytes of a file to determine a "magic number", which is compared against a known list of them. This is (at least part) of how the file command on Linux systems works.
Someone else asked a similar question and posted the code used to do exactly this. You should be able to take what is posted here, and slightly modify it so that it pulls from your database.
https://stackoverflow.com/questions/58510
In addition to that, it looks like someone has written a library based off of magic numbers to do this, however, it looks like the site requires registration, and some form of alternate access in order to download this lirbary. The documentation is avaliable for free without registration, that may be helpful.
http://software.topcoder.com/catalog/c_component.jsp?comp=13249160&ver=2
The easiest way I know is to use file command that it is also available in Windows with Cygwin .
A lot of filetypes have well defined headers that begin the file. You could check the first few bytes to check to see how the file begins.
Easiest way to do this would be through access to a *nix (or cygwin) system that has the 'file' command:
$ file visitors.*
visitors.html: HTML document text
visitors.png: PNG image data, 5360 x 2819, 8-bit colormap, non-interlaced
You could write a C# application that piped the first X bytes of each binary column to the file command (using - as the file name)
You need to use some p/invoke interop code to call the SHGetFileInfo method from the Win32 API. This article may also help.