<%@ Page Title="Strategy: tus 1.0 protocol" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" %> 
<asp:Content ID="TitleContent" ContentPlaceHolderID="TitleContent" runat="server">tus 1.0 protocol - AjaxUploader v5.2 Demos</asp:Content> 
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeaderTitle" runat="server">tus 1.0 protocol</asp:Content> 
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> 
<div class="demo-card"> <div class="demo-card-header">tus 1.0 resumable uploads</div> <div class="demo-card-body"> <p class="demo-description"> AjaxUploader ships a zero-dependency tus 1.0 client (Core + Creation + Termination extensions) and a filesystem-backed <code>TusStorage</code> class. Interoperates with tusd, uppy-companion, or any tus-1.0-compliant server. Works out of the box against the built-in endpoint - no extra wiring beyond registering the <code>ajaxupload.axd</code> handler in <code>web.config</code>.
 </p> <div class="d-flex gap-2 mb-2 mt-4">
 <button type="button" class="btn btn-primary" id="startBtn_tusUploader">Start upload</button>
 <button type="button" class="btn btn-outline-secondary" id="clearBtn_tusUploader">Clear queue</button>
 </div>
 <div id="tusUploader"></div> <script> (function () {
 function init() {
 if (!window.AjaxUploader || typeof AjaxUploader.create !== 'function') return; // graceful no-op if runtime missing
 var startButton = document.getElementById('startBtn_tusUploader');
 var clearButton = document.getElementById('clearBtn_tusUploader');
 var uploader = AjaxUploader.create('#tusUploader', {
 uploadUrl: '<%= ResolveUrl("~/ajaxupload.axd/upload") %>',
 strategy: 'tus',
 chunkSize: 5 * 1024 * 1024,
 autoUpload: false,
 multiple: true,
 persistState: true,
 persistAdapter: 'indexeddb'
 });
 if (startButton) startButton.addEventListener('click', function () { if (uploader && typeof uploader.upload === 'function') uploader.upload(); });
 if (clearButton) clearButton.addEventListener('click', function () { if (uploader && typeof uploader.clear === 'function') uploader.clear(); });
 }
 if (document.readyState !== 'loading') init();
 else document.addEventListener('DOMContentLoaded', init);
 })();
 </script> <div class="alert alert-info mt-3" role="alert"> <strong>Resume behaviour:</strong> if you reload the page during an upload, the resumed task does a <code>HEAD</code> on the stored tus URL, reads the server's current <code>Upload-Offset</code>, and <code>PATCH</code>es from there. No bytes are re-uploaded.
 </div> <h5 class="mt-4">Client config</h5> <div class="code-panel"> 
<pre><code>AjaxUploader.create('#uploader', {
 uploadUrl: '<%= ResolveUrl("~/ajaxupload.axd/upload") %>',
 strategy: 'tus',
 chunkSize: 5 * 1024 * 1024, <span style="color:#94a3b8">// PATCH chunk size</span> persistState: true,
 persistAdapter: 'indexeddb'
 <span style="color:#94a3b8">// tusEndpoint defaults to `{uploadUrl base}/tus` - override for tusd:</span> <span style="color:#94a3b8">// tusEndpoint: 'https://your-tusd-host/files/'</span> 
});</code></pre> </div> <h5 class="mt-4">Server-side</h5> <p>The default <code>ajaxupload.axd</code> handler registers the tus routes automatically. No additional code required.</p> <h5 class="mt-4">Wire protocol (tus 1.0.0)</h5> <ul class="mb-3"> <li><code>OPTIONS /ajaxupload.axd/tus</code> -> capabilities (<code>Tus-Version: 1.0.0</code>, <code>Tus-Extension: creation,termination</code>)</li> <li><code>POST /ajaxupload.axd/tus</code> -> <code>201</code> + <code>Location: /ajaxupload.axd/tus/{id}</code></li> <li><code>HEAD /ajaxupload.axd/tus/{id}</code> -> current <code>Upload-Offset</code> (used for resume)</li> <li><code>PATCH /ajaxupload.axd/tus/{id}</code> -> bytes with <code>Content-Type: application/offset+octet-stream</code></li> <li><code>DELETE /ajaxupload.axd/tus/{id}</code> -> cleanup on cancel / fatal error</li> </ul> <h5 class="mt-4">Third-party server interop</h5> <p>The same client works against any tus 1.0 server - just point <code>tusEndpoint</code> at it. Tested against <a href="https://tus.io/" target="_blank" rel="noopener noreferrer">tusd</a> and uppy-companion.</p> </div> 
</div> 
</asp:Content> 
