NSData Constructor
NSData Constructor
- Subject: NSData Constructor
- From: "Xia, Wen" <email@hidden>
- Date: Fri, 22 Oct 2004 10:44:44 -0700
I tried to upload am image file into database and it uploads fine. I used
different code as per below and both of them works just fine:
code segment 1:
FileInputStream inputFile = new FileInputStream(selectedFile);
thisGraph.setGraphic(new NSData(inputFile, inputFile.available()));
code segment 2: (works also)
FileInputStream inputFile = new FileInputStream(selectedFile);
thisGraph.setGraphic(new NSData(inputFile, (int)selectedFile.length()));
What is puzzling to me is that the output of inputFile.available() is 0.
And the output of selectedFile.length() is 3339, but the actual file size is
47313 bytes. And I looked into the doc for NSData(InputStream, int) method,
it says the second parameter "specifies the size, in bytes, of the block
that the input stream returns when it reads. For maximum performance, you
should set the chunk size to the approximate size of the data."
Since both of the code works, I wonder which is the right way of doing it.
Also, why the file.length() returns a different file size than the actual
size? The file size discrepancy only happens when I tried to upload a image
file (*.jpeg, *.gif), other types of objects like excel spreadsheet, word
doc, the file size matches.
Please advise me. Thanks in advance.
-- Wen X.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden