Enable user to download files in file system

已查看 50 次
跳至第一个未读帖子

Arthur Dou

未读,
2017年1月24日 23:11:022017/1/24
收件人 Native-Client-Discuss
Recently, I'm trying to develop a PNaCl program that generates (or process) some files & informs the user to download them.
After studying the official file IO example & an introduction of File system API, I edited the example in ~/pepper_49/examples/api/file_io 
and achieved my purpose through following (simplified) steps:
  1. After request quota through navigator.webkitPersistentStorage.requestQuota (as original example), 
    record used filesystem (in variable filesystem) through window.webkitRequestFileSystem
    (example.js)
  2. Generate files through FileIO, FileRef, FileSystem as the original example
    (file_io.cc)
  3. Pass the full path of a specified file to JavaScript side with PostMessage
    (file_io.cc)
  4. With variable filesystem, get the file entry through passing the full path to filesystem.root.getFile method. 
    Use the file entry to translate the path to URL with fileEntry.toURL method.
    In the end, paste the URL on index (through src or href)
    (example.js)
The approach above, in my point of view, strongly depends on that the file system at both side (PNaCl & JavaScript) 
are just the same (or kind of transformable), so I'm wondering:
  • Is the approach I figure out a occasional solution? (with pepper 49 & google chrome 55)
  • If it is, is there any other way to get the feature I need? (maybe... PPAPI will support translate path to URL in future revision?)
I will appreciate any of your replies; and please feel free asking me to provide more details if you need.

Best regards, 
Arthur

Ben Smith

未读,
2017年2月21日 22:50:552017/2/21
收件人 Native-Client-Discuss
Yes, the PPAPI FileSystem is the same one as used by JavaScript. So you can use the same path to access files in either.

Arthur Dou

未读,
2017年3月9日 05:15:592017/3/9
收件人 Native-Client-Discuss
Thanks so much for your reply! It's fairly important that the processed file is downloadable in our product.

Ben Smith於 2017年2月22日星期三 UTC+8上午11時50分55秒寫道:
回复全部
回复作者
转发
0 个新帖子