StageWebViewDisk Breaks the File Upload on iPad (i

2019-08-28 04:19发布

I'm using Adobe Air for iPad/iPhone application.

I'm also using StageWebViewBridge (https://github.com/paleozogt/StageWebViewBridge) as the main web content displaying container.

My application works well for the Desktop version, but the StageWebViewBridge's StageWebViewDisk breaks HTML File Uploading feature:

<input id="user_avatar" name="user[avatar]" style="width:100%" type="file" />

i.e., whenever a file is browsed and selected from either Take Photo or Video or Choose Existing from the real iPad device, the above user_avatar input does NOT get updated at all.

I believe some paths are messed up by StageWebViewDisk.initialize(stage).

You can find the full source of StageWebViewDisk here: https://github.com/paleozogt/StageWebViewBridge/blob/master/StageWebViewBridge/src/es/xperiments/media/StageWebViewDisk.as

And the following code snippet is very suspicious:

case isIPHONE :
    /* new iOS 5.0 Data Storage Guidelines
     * https://developer.apple.com/icloud/documentation/data-storage/
     * https://developer.apple.com/library/ios/#qa/qa1719/_index.html
     */
    _appCacheFile = new File(File.applicationDirectory.nativePath +"/\.\./Library/Caches");

    _applicationCacheDirectory = new File( _appCacheFile.nativePath ).url;
    _applicationRootPath = _applicationCacheDirectory + '/' + getWorkingDir();
    _applicationSourcesDirectory = new File( new File( "app:/" + _document_root ).nativePath ).url;
    _appDocsDirectory = File.documentsDirectory.url;

    /* new iOS 5.0 Data Storage Guidelines
     * https://developer.apple.com/icloud/documentation/data-storage/
     * https://developer.apple.com/library/ios/#qa/qa1719/_index.html
     */                 
    _applicationTempDir = new File(File.applicationDirectory.nativePath +"/\.\./tmp");

    // To acomplish the Apple  Data Storage Guidelines Rules delete our TMP files dir at exit
    NativeApplication.nativeApplication.addEventListener(Event.EXITING, deleteTempFolder,false,0,true );
    NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, deleteTempFolder, false, 0, true);                   

    break;

I debugged a lot, and I finally found out that StageWebViewDisk.initialize(stage) is causing issue.

The proof is that, when I don't use StageWebViewDisk.initialize(stage), instead, directly assign the stage to StageWebViewBridge._view.stage, it works very well.

I'm not familiar with the iOS app/cache directories.

Please advise me.

1条回答
狗以群分
2楼-- · 2019-08-28 04:31

I finally figured it out:

_applicationTempDir = new File(File.applicationDirectory.nativePath +"/\.\./SWVBTmp");
// It seems "tmp" is being used by the iOS system (such as the html file upload), so we changed to "SWVBTmp"; 
查看更多
登录 后发表回答