Guest User

Untitled

a guest
May 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. Assets V2
  2. ========
  3.  
  4. SDK
  5. ====
  6.  
  7. Async assets
  8. --------------------
  9.  
  10. * Assets can be created without a synchronous file post
  11. * File can be supplied after the fact
  12. * Files supplied post-creation go to ingest URL in a seperate request in >=1 post
  13. * SDK can build ingest URLs (ingest.videojuicer.com/seed/asset_type/key)
  14.  
  15. Core API
  16. =======
  17.  
  18. The ingest service supports server-side progress monitoring for current browsers and chunked posting and stitching for future browsers (starting with FF 3.6).
  19.  
  20. Creating a chunk-ingested asset...
  21.  
  22. * Create a _non-derived_ asset without file
  23. * Assets like this report back an ingest key (possibly a UUID - anything random)
  24. * continue to support direct posting for smaller files (synchronous workflow)
  25. * new states: ingesting, ingested
  26. -- may wish to update state ingesting -> ingesting every time a chunk is received
  27.  
  28. Ingest Service (can't be part of core as it can't sit behind ELB)
  29. * note this has to be a single service on a single instance - no load balancing
  30. -- possible JVM candidate (scala?)
  31. * secret key handshake needed between core -> user -> ingest...
  32. -- panel has rights to create asset -> so _authorized_ consumers get an ingest key back
  33. -- ingest key is then provided back to ingest service (ingest URL) which can do a secure lookup on core
  34. * runs a chunked posting service which will only actually employ chunking when the client supports FileReader
  35. * when the client is chunking, each part is provided along with a file offset, for later re-stitching by the service
  36. * note that no checksumming is strictly required here as each portion of data is being handled by the browser's own plumbing rather than routing through Flash
  37. * receives final 'done' from the client and commences stitching / shuts down write credentials
  38. * updates core with the source_uri that the ingest service is now ready to serve
  39.  
  40. State timeline
  41. --------------------
  42. create: pending
  43. post to ingest service: ingesting
  44. post 'completion' to ingest service: ingested
  45. -> back to normal -> to_acquire, acquiring, to_stow, stowing, ready
  46.  
  47.  
  48. Panel
  49. =====
  50.  
  51. Upload workflow
  52. ------------------------
  53.  
  54. Javascript namespace
  55. ---------------------------------
  56.  
  57. AssetUpload - A single file upload which presents methods for getting progress and other state information, as well as starting/cancelling/resuming(?) an upload
  58. AssetUploadController - The singleton class which maintains the stack of all active, failed and completed AssetUpload instances and provides logic for querying and displaying this state
  59.  
  60. AssetUploadStrategy - An abstract class that provides an interface for presenting a file selection field to the user, posting that data to the server, and retrieving the state for that AssetUpload. A single AssetUpload instance may use any strategy, but in practice we will configure the strategy for ALL AssetUpload instances when the application first loads by attempting to reference the FileReader class and catching the raised exception. An AssetUpload is instantiated with a JSON hash of asset properties for the asset we will be populating.
  61.  
  62. AssetUploadFileReaderStrategy - The new and shiny FileReader-based strategy.
  63. AssetUploadIFrameStrategy - The old and busted hackety-hack iframe shite.
  64. AssetUploadFlashStrategy - Something we will hopefully never have to build.
  65.  
  66. Fallback (when features not available in browser)
  67. ---------------------------------------------------------------------
  68.  
  69. * Use framed synchronous post and server-side progress reporting
  70. * Each upload "job" contains a single file and is represented by an iframe containing something like:
  71.  
  72. <iframe src="/assets/new?async=false&id=12"></iframe>
  73. which contains:
  74. <form action="uploader.lol" enctype="manypartslol" id="uploader">
  75. <input type="file" name="thefile" />
  76. </form>
  77. <script type="text/javascript">
  78. // some code that repeatedly polls server for progress data
  79. function pollLol() {
  80. jobState = // get job state from server as JSON
  81. var bytesLoaded = jobState["bytesLoaded"]
  82. var bytesTotal = jobState["bytesTotal"]
  83. }
  84. setInterval(pollLol, 500);
  85. </script>
  86.  
  87. * given the iframe has an id of upload_controller_12:
  88. * We can call $("#upload_controller_12").document.forms[0].submit(); to control the submit of the form
  89.  
  90. Each upload strategy is a module which provides methods for:
  91.  
  92. * Displaying a file selector element
  93. * Posting the file to a URL
  94. // FileReader strategy: fileReader.post(url, etc. etc.)
  95. // IFrame strategy: $("theiframe").document.forms[0].submit();
  96. * Retrieving the job's state and progress
  97.  
  98. Recovery from failure
  99. -------------------------------
Add Comment
Please, Sign In to add comment