The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Upload.cshtml 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. @model Teknik.Areas.Help.ViewModels.HelpViewModel
  2. @using Teknik.Utilities
  3. @Styles.Render("~/Content/help");
  4. <div class="container">
  5. <ol class="breadcrumb">
  6. <li><a href="@Url.SubRouteUrl("help", "Help.Index")">Help Index</a></li>
  7. <li><a href="@Url.SubRouteUrl("help", "Help.API", new { version = string.Empty, service = string.Empty })">API</a></li>
  8. <li>v1</li>
  9. <li class="active"><a href="#">Upload Service</a></li>
  10. </ol>
  11. <div class="row api">
  12. <h2><b>Upload Service</b></h2>
  13. <hr>
  14. <p>This is a description of the API commands available for the Upload service.</p>
  15. <h3>Upload a File</h3>
  16. <pre><code>POST @Url.SubRouteUrl("api", "API.v1.Upload")</code></pre>
  17. <h4>Headers</h4>
  18. <table>
  19. <thead>
  20. <tr>
  21. <th>Name</th>
  22. <th>Value</th>
  23. <th>Default Value</th>
  24. <th>Description</th>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. <tr>
  29. <td>
  30. <code>Authorize</code>
  31. </td>
  32. <td>
  33. <code>Basic <i>Encoding.Base64</i>(&lt;username&gt;:&lt;token&gt;)</code>
  34. </td>
  35. <td>
  36. <var>NULL</var>
  37. </td>
  38. <td>
  39. Basic Authentication to associate the upload with your account.
  40. </td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. <h4>Parameters</h4>
  45. <table>
  46. <thead>
  47. <tr>
  48. <th>Name</th>
  49. <th>Type</th>
  50. <th>Default</th>
  51. <th>Description</th>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <tr>
  56. <td>
  57. <code>file</code>
  58. </td>
  59. <td>
  60. <code>file</code>
  61. </td>
  62. <td>
  63. <var>NULL</var>
  64. </td>
  65. <td>
  66. <strong>Required</strong>
  67. The file that you would like to upload.
  68. </td>
  69. </tr>
  70. <tr>
  71. <td>
  72. <code>contentType</code>
  73. </td>
  74. <td>
  75. <code>string</code>
  76. </td>
  77. <td>
  78. <var>no</var>
  79. </td>
  80. <td>
  81. The content-type of the file you are uploading. Only required if the file being uploaded is already encrypted.
  82. </td>
  83. </tr>
  84. <tr>
  85. <td>
  86. <code>encrypt</code>
  87. </td>
  88. <td>
  89. <code>bool</code>
  90. </td>
  91. <td>
  92. <var>true</var>
  93. </td>
  94. <td>
  95. If you want the file to be encrypted server side. This will regenerate the key and/or iv if none are passed in.
  96. </td>
  97. </tr>
  98. <tr>
  99. <td>
  100. <code>saveKey</code>
  101. </td>
  102. <td>
  103. <code>bool</code>
  104. </td>
  105. <td>
  106. <var>true</var>
  107. </td>
  108. <td>
  109. Saves the passed in or generated key to the server. This will make it so that on download, the file will decrypt server side.
  110. </td>
  111. </tr>
  112. <tr>
  113. <td>
  114. <code>key</code>
  115. </td>
  116. <td>
  117. <code>string</code>
  118. </td>
  119. <td>
  120. <var>NULL</var>
  121. </td>
  122. <td>
  123. If you want the file to be decrypted server side, include the key.
  124. </td>
  125. </tr>
  126. <tr>
  127. <td>
  128. <code>keySize</code>
  129. </td>
  130. <td>
  131. <code>int</code>
  132. </td>
  133. <td>
  134. <var>@Model.Config.UploadConfig.KeySize</var>
  135. </td>
  136. <td>
  137. The size of the key provided in bytes. Only needed if encrypting and no key is provided.
  138. </td>
  139. </tr>
  140. <tr>
  141. <td>
  142. <code>iv</code>
  143. </td>
  144. <td>
  145. <code>string</code>
  146. </td>
  147. <td>
  148. <var>NULL</var>
  149. </td>
  150. <td>
  151. If the file has been encrypted and you want it decrypted (Both Server and Client Side), include the iv.
  152. </td>
  153. </tr>
  154. <tr>
  155. <td>
  156. <code>blockSize</code>
  157. </td>
  158. <td>
  159. <code>int</code>
  160. </td>
  161. <td>
  162. <var>@Model.Config.UploadConfig.BlockSize</var>
  163. </td>
  164. <td>
  165. The size of the iv provided in bytes. Only needed if encrypting and no iv is provided.
  166. </td>
  167. </tr>
  168. <tr>
  169. <td>
  170. <code>genDeletionKey</code>
  171. </td>
  172. <td>
  173. <code>bool</code>
  174. </td>
  175. <td>
  176. <var>false</var>
  177. </td>
  178. <td>
  179. Generates a deletion key.
  180. </td>
  181. </tr>
  182. <tr>
  183. <td>
  184. <code>doNotTrack</code>
  185. </td>
  186. <td>
  187. <code>bool</code>
  188. </td>
  189. <td>
  190. <var>false</var>
  191. </td>
  192. <td>
  193. If you do not want the api request to be tracked as defined in the privacy policy.
  194. </td>
  195. </tr>
  196. </tbody>
  197. </table>
  198. <h4>Response</h4>
  199. <pre><code>{"result":{"url":"<var>url</var>", "fileName":"<var>fileName</var>", "contentType":"<var>contentType</var>", "contentLength":<var>contentLength</var>, "key":<var>key</var>, "keySize":<var>keySize</var>, "iv":<var>iv</var>, "blockSize":<var>blockSize</var>, "deletionKey":<var>deletionKey</var>}}</code></pre>
  200. <table>
  201. <thead>
  202. <tr>
  203. <th>Name</th>
  204. <th>Type</th>
  205. <th>Description</th>
  206. </tr>
  207. </thead>
  208. <tbody>
  209. <tr>
  210. <td>
  211. <code>url</code>
  212. </td>
  213. <td>
  214. <code>string</code>
  215. </td>
  216. <td>
  217. The direct url to the uploaded file. The key is apended to the url as an anchor tag.
  218. </td>
  219. </tr>
  220. <tr>
  221. <td>
  222. <code>fileName</code>
  223. </td>
  224. <td>
  225. <code>string</code>
  226. </td>
  227. <td>
  228. The filename of the uploaded file.
  229. </td>
  230. </tr>
  231. <tr>
  232. <td>
  233. <code>contentType</code>
  234. </td>
  235. <td>
  236. <code>string</code>
  237. </td>
  238. <td>
  239. The MIME file type of the uploaded file.
  240. </td>
  241. </tr>
  242. <tr>
  243. <td>
  244. <code>contentLength</code>
  245. </td>
  246. <td>
  247. <code>integer</code>
  248. </td>
  249. <td>
  250. The size of the uploaded file in bytes.
  251. </td>
  252. </tr>
  253. <tr>
  254. <td>
  255. <code>key</code>
  256. </td>
  257. <td>
  258. <code>string</code>
  259. </td>
  260. <td>
  261. <strong>Optional</strong>
  262. The key that was used to encrypt the file.
  263. </td>
  264. </tr>
  265. <tr>
  266. <td>
  267. <code>keySize</code>
  268. </td>
  269. <td>
  270. <code>int</code>
  271. </td>
  272. <td>
  273. The size of the key used in bytes.
  274. </td>
  275. </tr>
  276. <tr>
  277. <td>
  278. <code>iv</code>
  279. </td>
  280. <td>
  281. <code>string</code>
  282. </td>
  283. <td>
  284. <strong>Optional</strong>
  285. The iv that was used to encrypt the file.
  286. </td>
  287. </tr>
  288. <tr>
  289. <td>
  290. <code>blockSize</code>
  291. </td>
  292. <td>
  293. <code>int</code>
  294. </td>
  295. <td>
  296. The size of the iv used in bytes.
  297. </td>
  298. </tr>
  299. <tr>
  300. <td>
  301. <code>deletionKey</code>
  302. </td>
  303. <td>
  304. <code>string</code>
  305. </td>
  306. <td>
  307. <strong>Optional</strong>
  308. The deletion key for file. Use it as follows: <code>@Url.SubRouteUrl("u", "Upload.Delete", new { file = "file.jpg", key = "deletionKey" })</code>
  309. </td>
  310. </tr>
  311. </tbody>
  312. </table>
  313. <h4>Example</h4>
  314. <pre><code>$ curl -F "genDeletionKey=true" -F "encrypt=true" -F "file=@("@")image.png" @Url.SubRouteUrl("api", "API.v1.Upload")</code></pre>
  315. <p>
  316. This will upload the file <var>image.png</var>, encrypt it, and then generate a deletion key.
  317. </p>
  318. <br />
  319. <br />
  320. </div>
  321. </div>