public static AssetStoreClient.Pending CreatePendingPost(string name, string path, string postData, AssetStoreClient.DoneCallback callback) { AssetStoreClient.Pending p = AssetStoreClient.CreatePending(name, callback); AssetStoreClient.PendingQueueDelegate pendingQueueDelegate = delegate { p.conn = AssetStoreClient.AcquireClient(); if (p.conn == null) { return(false); } try { p.conn.Headers.Set("X-Unity-Session", AssetStoreClient.ActiveOrUnauthSessionID); p.conn.UploadProgressChanged += new UploadProgressChangedEventHandler(AssetStoreClient.UploadProgressCallback); p.conn.UploadStringCompleted += new UploadStringCompletedEventHandler(AssetStoreClient.UploadStringCallback); p.conn.UploadStringAsync(AssetStoreClient.APIUri(path), "POST", postData, p); } catch (WebException ex) { p.ex = ex; return(false); } return(true); }; if (!pendingQueueDelegate()) { p.queueDelegate = pendingQueueDelegate; } return(p); }
public void Open() { try { this.RequestFileStream = new FileStream(this.FilePath, FileMode.Open, FileAccess.Read); this.Request = (HttpWebRequest)WebRequest.Create(AssetStoreClient.APIUri(this.URI, this.m_extraParams)); this.Request.AllowWriteStreamBuffering = false; this.Request.Timeout = 36000000; this.Request.Headers.Set("X-Unity-Session", AssetStoreClient.ActiveOrUnauthSessionID); this.Request.KeepAlive = false; this.Request.ContentLength = this.RequestFileStream.Length; this.Request.Method = "PUT"; this.BytesToSend = this.RequestFileStream.Length; this.BytesSent = 0L; this.RequestStream = this.Request.GetRequestStream(); if (this.Buffer == null) { this.Buffer = new byte[32768]; } } catch (Exception ex) { AssetStoreResponse job = AssetStoreClient.parseAssetStoreResponse(null, null, ex, null); this.RequestDoneCallback(job); this.Close(); throw ex; } }
public static AssetStoreClient.Pending CreatePendingUpload(string name, string path, string filepath, AssetStoreClient.DoneCallback callback) { DebugUtils.Log("CreatePendingUpload"); AssetStoreClient.Pending pending = AssetStoreClient.CreatePending(name, callback); AssetStoreClient.PendingQueueDelegate pendingQueueDelegate = () => { bool flag; pending.conn = AssetStoreClient.AcquireClient(); if (pending.conn == null) { return(false); } try { pending.conn.Headers.Set("X-Unity-Session", AssetStoreClient.ActiveOrUnauthSessionID); pending.conn.UploadProgressChanged += new UploadProgressChangedEventHandler(AssetStoreClient.UploadProgressCallback); pending.conn.UploadFileCompleted += new UploadFileCompletedEventHandler(AssetStoreClient.UploadFileCallback); pending.conn.UploadFileAsync(AssetStoreClient.APIUri(path), "PUT", filepath, pending); return(true); } catch (WebException webException) { pending.ex = webException; flag = false; } return(flag); }; if (!pendingQueueDelegate()) { pending.queueDelegate = pendingQueueDelegate; } return(pending); }
private static Uri APIUri(string path) { return(AssetStoreClient.APIUri(path, null)); }