How do I use a FileStream with an IFilePromise without knowing the File?

I've finished the implmentation of my project using Async IFilePromises by extending the ByteArray class. I can drag out of my application and files are created by copying bits over the network, etc. The issue I'm running into is that because I used the ByteArray as my dataprovider, files are stored "In-Memory" until the Close event is fired.
My application routinely copies files around 700 MB and up to 2 GB. The implementation quickly causes out of memory errors. That said, if I change the implementation to use FileStreams then the files are written directly to disk and memory is exactly where I want it to be.
The issue is that the FileStream requires a File object when it's FileStream.open(File, FileMode) method is called. If I manually create a file and use it, then everything is fine, but doing that defeats the purpose of the FilePromise. I lose all the information about where a person dropped the file.
So how do I get access to the File object that is created for each FilePromise? I know one is created by inspecting the call stack when the IFilePromise.open() method is called and inspecting the caller MacFilePromiseWrapper._file.
I've tried simply returning a plain FileStream instead of an extended class in the IFilePromise.open method, but that still gives the same error result when I try to write to the stream (says that the stream isnt open yet).
I would have expected the MacFilePromiseWrapper / FilePromiseWrapper to intelligently handle the returned IDataProvider and perform any "open" and "close" it needed. Please tell me I'm just missing something obvious. I'm so close to being done with this project and I don't want to have to rewrite this using a native implementation. The performance issues (memory usage) will cause me to do just that if I cant figure this out.
Thanks for any help,
Jared

I have resolved the issues myself.
I had the idea of an IFilePromise / IDataInput backwards. The way I thought it worked is that what you were "writing to" when you wrote into a ByteArray and fired of progress events was simply a pipe to a file handle on the disk. That's backwards.  What really happens is that the thing you're writing to is a buffer for the IFilePromise. Firing the open/progress/close events let the file system know that it's safe to pull up to IDataInput.bytesAvailable out of your buffer and write that to the disk and the buffer you write to can be a ByteArray, Socket, FileStream, etc.
The confusion was compounded by my attempts to use FileStream as the IDataInput. What I was doing for "testing purposes" was creating a temporary file and writing my bytes to it. The file handle created by the FilePromise would immediately disappear, so I thought it meant I needed to somehow get access to that handle so I knew where to send my bits using FileStream.open(File, FileMode).
I was really close, but had a mistake in there.  I was on the right track with opening the FileStrea and using the temporary file, but I opened it with the wrong FileMode.
I used FileMode.WRITE because I thought I was writing to the disk only. When I switched it to FileMode.UPDATE (which is read/write) then everything worked as I needed it to.
So to summarize, to use a FileStream as the IDataInput for an IFilePromise you need to:
Create the FileStream object and return it when the IFilePromise.open is called
When you get bytes off your network, etc, dispatch the OPEN event
Open the FileStream object with FileMode.UPDATE and use a temporary file provided by File.createTempFile(), store it for later
Write bytes to the FileStream and send out the proper ProgressEvent.PROGRESS events
Dispatch the COMPLETE event when you're done
the IFilePromise.end() method will be called and you have an opportunity to close your FileStream and to delete the temporary file that was created
I hope this helps someone that runs into a similar issue.

Similar Messages

  • How do I use a path as an argument without breaking the -classpath option?

    How do I use a path as an argument without breaking the -classpath option?
    I have the following Korn Shell Script:
    #!/bin/ksh
        CSVFILE=/EAIStorageNumbers/v1/0001/weekly05222006.csv
        OUTPUTFILE=/EAIStorageNumbers/v1/0001/08000000.txt
        PAGEMBR=0800F341
        cd /EAIStorageNumbers/v1/bin/
        java -classpath com.dtn.refinedfuels.EAIStorageNumbers $CSVFILE $OUTPUTFILE $PAGEMBRWhen I run the shell script, I return the following error:
    Exception in thread "main" java.lang.NoClassDefFoundError: /EAIStorageNumbers/v1/0001/weekly05222006/csv
    Thus, the -classpath option sees the first argument as a classpath. When I remove the -classpath option, I get a different error, which is another issue:
    Exception in thread "main" java.lang.NoClassDefFoundError: au/com/bytecode/opencsv/CSVReader
    at com.dtn.refinedfuels.EAIStorageNumbers.main(Unknown Source)
    Thoughts or suggestions on how I can get the -classpath option to work with the defined Korn Shell Script variables would be greatly appreciated.

    I think you're misunderstanding the classpath argument. This tells java where to look to find your classes. The argument you're supplying looks like the class that you want java to run. Run something like this: java -classpath $MY_CLASS_DIR my.package.MyClass arg1 arg2 arg3.

  • How can I sync my iPod with my computer without deleting the songs that are on my ipod

    how can I sync my iPod with my computer without deleting the songs that are on my ipod

    See this post by forum regular Zevoneer on transferring files from the iPod to your computer.
    tt2

  • My iphone 4s is 2nd ...then i format..the phone want old user id...how can i used that iphone back because i dont know the id?

    My iphone 4s is 2nd ...then i format..the phone want old user id...how can i used that iphone back because i dont know the id?

    There is no other solution - as you have already been told, if you don't have that user id and you cannot contact the previous owner of that id for the phone, then there is absolutely nothing that you can do.  You have a useless brick that you can't use.
    Nothing else to do.

  • But how do I create a new iTunes backup password without knowing the previous one?

    In case anyone keeps track of such things, I'm among those folks who really doesn't recall ever being asked to create an iTunes backup password, but that's irrelevant to my question.
    I'm not in any bind. I don't need my backup files to restore anything. I will shed no tears as they are moved to the Recycle Bin (indeed, I will gladly do the deed myself).
    That said, it appears impossible to create a new backup password without knowing the previous one.
    If the only "solution" is to wipe my iPhone's memory and start from scratch, I will be a sad camper.
    Any help? Are backups to iCloud encrypted?
    Cheers...

    Additionally:
    Be super critical & meticulous (and whatever other synonym I missed) when you get a new password:
    Write it onto your bedroom wall, or someplace off of a computer that you will always find.
    If you active 2-step verification, the key is VERY important. Lose it & you may be toast.
    If you don’t 2 step verify, & use the Security Question instead --> do not lose, or forget the answers.
    Very nearly the same outcome!!!!!:  Bad experience.
    If you add a 2nd email address, make sure its a RESCUE address not just an alternate address.
    If you lose these, you lose access to your 3rd party purchases via Appstore for future upgrade. That will make you VEWY, VEWY UNHAPPY. Apple new OS versions do update, but add a new device & likely you will be unable to use your content on that device. It will never load if the ID locks up.

  • How do i reset an iPad to factory settings without knowing the passcode?

    We laid off an employee but don't have his passcode to reset the ipad to it's factory settings.  Is there anyway I can do this?  I tried following the directions I found:
    If you don’t know the passcode to go into the ipad and reset it, you simply need to connect the iPad to iTunes.
    Connect your iPad to the USB port on your computer, open iTunes and on the left side of the panel will appear a category for Devices... select the iPad. The summary window will have the information on the iPad and below that the choice for Restore. Select Restore, and you will have to do some confirming usually, and the system will go to work restoring the iPad to the factory settings.
    But it says it won't connect to iTunes until I enter the passcode:  "iTunes could not connect to the iPad ****** because it is locked with a passcode.  You must enter your passcode on the iPad before it can be used with iTunes."
    Any ideas?
    Marcine

    Put the iPad into Recovery Mode and then try the Restore again:
    http://support.apple.com/kb/ht1808
    If that still doesn't work, as a last resort try DFU mode:
    http://osxdaily.com/2010/12/04/ipad-dfu-mode/
    Regards.

  • How do I show iTunes my WMP music library without duplicating the files

    I have kind of a lot of music on my Dell PC... most of my music is MP3 format. I like it that way, sometimes I want to use my old, dumb MP3 player to play music, so I can us my iPhone for more important things like, txting, talking to a person via the 'phone' feature, navigation, etc.... all without interruption to my music play-back.... so, I realized a while ago that whenever I 'show' iTunes music in my existing WMP library, it would duplicate the files and place them inside an iTunes folder, inside the 'My Music' folder. I'm sure there is a way to point my iTunes library to use the existing MP3 library, without it duplicating.... I just haven't been able to figure it out. Now I'm maxing use of 75Gigs of music storage... I think I'm going to have to resolve this duplication issue if I want to keep ripping my CDs onto my HD.  Please don't suggest that I convert everything to iTunes and delete the WMP library.  I'd love to do that, IF iTunes weren't so fat and invassive to run. That program has gotten too fat & slow.... (yeah, I know, WMP is catching up). Often, I just want to add some tracks to a device without the software inventorying my entire device before it will add a cpouple of tracks. For that, (I can't beleive I'm saying this) but I actually will use WMP whenever possible. iTunes is just too big, slow & bossy. So, can anyone help me out here? How do I get i-Tunes to see & use my WMP library w/out duplicating the files... just using the "My Music" folder as is? I'm sure someone told me that was possible.  Many thanks!

    Follow the directions here:
    https://discussions.apple.com/docs/DOC-3141

  • How can I use One Plugin with all his outputs on the region

    Hi All
    In Cubase I have a PlugIn Manager and when I have a Plugin like Omnisphere with 8 outputs I can route each output on one sequencer region.
    Can I do This as same in Logic?
    Exemple
    I will open a new Midi Instrument on a region. Than I Know I have 8 outputs and than I will have 8 Lines and each line I will create Midi comandos for each output separatly.
    can I do this? Or any Idee how can I do this?
    Thanks for help
    Marco

    When you load a plug-in that's capable of multi-output, you do have a menu choice about that when you load it, yeah ?
    You can create the additional channels that you need in the mixer - press the '+' button on the channel strip and it does it for you.

  • How do I sync my iphone with my itunes without deleting the music that I have on my iphone?

    I just recently had my computer (windows) wiped because my hard drive crashed and I had to re- download itunes. When I try to sync my iphone to the new itunes I had to download, it keeps telling me my iphone doesnt recognize the new one I downloaded and it has to delete all the songs on my iphone to replace it with the itunes I just downloaded, which has no songs. Is there anyway I can just continue adding new songs onto my iphone without having to delete all the songs on it?!? help

    See these 2 Links...
    Recovering your iTunes library from your iPod or iOS device
    https://discussions.apple.com/docs/DOC-3991
    Syncing to a New Computer...
    https://discussions.apple.com/docs/DOC-3141

  • How can I use my account if I don't know the answers to my security questions?

    When I go to buy something from the app store or iTunes it will make me answer my security questions but any answer I put doesn't go through so i'm trying to find a way to figure out how I can get in.

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    (124282)

  • How do you use an iPad with Apple TV

    How do I use an iPad with Apple TV?

    Read the iPad manual:  http://support.apple.com/manuals/#ipad
    See this article: http://support.apple.com/kb/HT4437

  • How can i use MS word with MAVERICK

    how can i use MS word with MAVERICK?  None of the MS Office applications work with new IOS!!!

    What version of Microsoft Office Mac are you running?  You probably just need to update it to the latest release:
    http://www.microsoft.com/mac/downloads?pid=Mactopia_Office2011
    Office 2011 Mac's latest version is 14.3.8 for instance.

  • How do you unlock an ipod touch without knowing the password

    How do you unlock a ipod touch 4th generation without knowing the password?

    Connect the iOS device to your computer and restore via iTunes. Place the iOS device in Recovery Mode if necessary to allow the restore.
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • How do I use my ipad with Apple TV?

    How do i use my iPad2 with Apple TV?

    If it's an ATV2 or 3, you can use AirPlay. AirPlay automatically becomes available when the two devices are on the same Wi-Fi network.
    HOWEVER! You should be aware of that AirPlay is, in some circumstances, far inferior to VGA / HDMI-cabled solutions. Please see my posts at https://discussions.apple.com/message/18697551?ac_cid=sa123456#18697551 for more info.

  • How do I use apple remote with iPhone 5 ?

    How do I use apple remote with iPhone 5 ?

    Iphones dont have ir at all which the remote use for comm
    Only option is to use a dock which have ir

Maybe you are looking for