by
29 3
0
3
72
1
Top 10% !
Specified
Tuned
Created
Modified Apr 21, 2017
This snippet is Public
No tags for this snippet yet.
InputName0release
InputName1resourceBytes
InputName2cookieid
InputType0Release
InputType1byte[]
InputType2string
Languagenimrod
LicenseMIT_X11
MethodNameUploadRelease
OutputTypeOperationResult

esp

post this code
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1753324/esp?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public OperationResult UploadRelease(Release release, byte[] resourceBytes, string cookieid) { ESPUploadSites uploadsite = ESPUploadSites.USWest; ESPBatch batch = lastbatch; OperationError error = null; OperationResult opresult = null; int partno = 1; string csrftoken = ""; string fname = GetESPReleaseFileName(release.Name); string time = Tools.GetJavaScriptTime(DateTime.Now).ToString(); string date = ""; string auth = ""; string uploadid = ""; string data = ""; string rid = ""; TimeSpan zero1 = TimeSpan.Zero; List<string> etags = new List<string>(); HTTPRequest r = GetMainPageRequest(cookieid); opresult = AuthenticatedRequest(r, Authorize, CheckAuthNotLost, null); if (!opresult.Success) return opresult; if (!ParseMainPage(r, ref csrftoken, ref error)) return new OperationResult(error); r = GetReleaseUploadInitRequest(batch.ID, time, fname, uploadsite, cookieid); HTTPRequestResult result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!ParseReleaseUploadInitResponse(r, ref date, ref auth, ref error)) return new OperationResult(error); r = GetReleaseUploadStartOptionsRequest(batch.ID, time, fname, uploadsite, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!CheckReleaseUploadStartOptionsResponse(r, ref error)) return new OperationResult(error); r = GetReleaseUploadStartRequest(batch.ID, time, fname, uploadsite, date, auth, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!ParseReleaseUploadStartRequest(r, ref uploadid, ref error)) return new OperationResult(error); long length = resourceBytes.Length; string chunkhash = Tools.GetSHA256(resourceBytes); TimeSpan zero2 = TimeSpan.Zero; r = GetReleaseUploadChunkInitRequest(batch.ID, time, fname, chunkhash, partno, uploadid, uploadsite, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!ParseReleaseUploadChunkInitResponse(r, ref date, ref auth, ref error)) return new OperationResult(error); r = GetReleaseUploadChunkOptionsRequest(batch.ID, time, fname, uploadid, partno, uploadsite, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!CheckReleaseUploadChunkOptionsResponse(r, ref error)) return new OperationResult(error); r = GetReleaseUploadChunkRequest(batch.ID, time, fname, uploadid, partno, uploadsite, resourceBytes, chunkhash, date, auth, cookieid); //Is long result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!CheckReleaseUploadChunkResponse(r, ref error)) return new OperationResult(error); r = GetReleaseUploadChunksListInitRequest(batch.ID, time, fname, uploadid, uploadsite, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!ParseReleaseUploadChunksListInitResponse(r, ref date, ref auth, ref error)) return new OperationResult(error); r = GetReleaseUploadChunksListOptionsRequest(batch.ID, time, fname, uploadid, uploadsite, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!CheckUploadChunkOptionsResponse(r, ref error)) return new OperationResult(error); r = GetReleaseUploadChunksListRequest(batch.ID, time, fname, uploadid, uploadsite, date, auth, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!ParseReleaseUploadChunksListResponse(r, etags, ref error)) return new OperationResult(error); data = GetUploadCompleteData(etags.ToArray()); chunkhash = Tools.GetSHA256(Encoding.ASCII.GetBytes(data)); r = GetReleaseUploadCompleteInitRequest(batch.ID, time, fname, uploadid, uploadsite, chunkhash, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!ParseReleaseUploadCompleteInitResponse(r, ref date, ref auth, ref error)) return new OperationResult(error); r = GetReleaseUploadCompleteRequest(batch.ID, time, fname, uploadid, uploadsite, date, auth, data, chunkhash, cookieid); result = HTTP.ExecSync(r); if (result != HTTPRequestResult.Success) return new OperationResult(result, r, StockId); if (!CheckReleaseUploadCompleteResponse(r, batch.ID, time, fname, ref error)) return new OperationResult(error); r = GetReleaseCreateRequest(batch, release, time, fname, csrftoken, cookieid); result = HTTP.ExecSync(r); return result == HTTPRequestResult.Success ? (ParseReleaseCreateResponse(r, release, ref rid, ref error) ? new OperationResult(false) : new OperationResult(error)) : new OperationResult(result, r, StockId); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus