fixes the put
This commit is contained in:
@ -13,7 +13,7 @@ isnd&
|
||||
# get an api-key from <http://localhost:5000/ApkKeys>
|
||||
|
||||
isn push -k <lame-api-key> -s http://localhost:5000/index.json your-lame-versionned.nupkg
|
||||
|
||||
wget http://localhost:5000/package/index.json?q=your&prerelease=true&semVerLevel=2.0.0
|
||||
````
|
||||
|
||||
## Installation
|
||||
@ -21,7 +21,7 @@ isn push -k <lame-api-key> -s http://localhost:5000/index.json your-lame-version
|
||||
Depuis le dossier de la solution, compiler la solution :
|
||||
|
||||
````bash
|
||||
dotnet build /restore
|
||||
dotnet build /restore -c Release
|
||||
dotnet publish -c Release
|
||||
````
|
||||
|
||||
@ -50,6 +50,7 @@ sudo systemctl start isnd
|
||||
sudo systemctl enable isnd
|
||||
````
|
||||
|
||||
|
||||
### Installer le client
|
||||
|
||||
````bash
|
||||
@ -77,7 +78,6 @@ sudo cp -a src/isn/bin/Release/net472/* /usr/local/lib/isn
|
||||
sudo chmod +x /usr/local/lib/isn/isn.exe
|
||||
````
|
||||
|
||||
|
||||
## TODO
|
||||
|
||||
````bash
|
||||
@ -85,4 +85,3 @@ isn add
|
||||
isn set-api-key
|
||||
isn sources
|
||||
````
|
||||
|
||||
|
@ -24,11 +24,8 @@ namespace nuget_cli
|
||||
try
|
||||
{
|
||||
var wrqueryHandler = new UploadFilesToServerUsingWebRequest();
|
||||
await wrqueryHandler.UploadFilesToServerAsync(report, new Uri(source), fi, apikey);
|
||||
#if FAILS
|
||||
var hcqueryHandler = new HttpClientServerQueryHandler();
|
||||
await hcqueryHandler.UploadFilesToServerAsync(report, new Uri(source), fi, apikey);
|
||||
#endif
|
||||
// await wrqueryHandler.UploadFilesToServerAsync(report, new Uri(source), fi, apikey);
|
||||
wrqueryHandler.UploadFilesToServer(report, new Uri(source), fi, apikey);
|
||||
|
||||
}
|
||||
catch (WebException ex)
|
||||
|
@ -15,6 +15,81 @@ namespace nuget_cli
|
||||
}
|
||||
public class UploadFilesToServerUsingWebRequest
|
||||
{
|
||||
internal void UploadFilesToServer(PushReport report, Uri uri, FileInfo fi,
|
||||
string apikey)
|
||||
{
|
||||
// string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
|
||||
const int TXLEN = 0x1000;
|
||||
/// the form-data file upload, properly formatted
|
||||
string fileheaderTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\";\r\nContent-Type: {2}\r\n\r\n";
|
||||
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
|
||||
// "X-NuGet-ApiKey
|
||||
string boundary = "----------" + DateTime.Now.Ticks.ToString("x");
|
||||
string fileheader = string.Format(fileheaderTemplate, "file", fi.Name, "application/octet-stream");
|
||||
byte[] fileheaderbytes = Encoding.ASCII.GetBytes(fileheader);
|
||||
var boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
|
||||
var endBoundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--");
|
||||
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
|
||||
|
||||
httpWebRequest.Method = "PUT";
|
||||
httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||
httpWebRequest.AllowAutoRedirect = false;
|
||||
httpWebRequest.Headers.Add("X-NuGet-Client-Version", Constants.ClientVersion);
|
||||
httpWebRequest.Headers.Add("X-NuGet-ApiKey", apikey);
|
||||
httpWebRequest.ContentLength = boundarybytes.Length +
|
||||
fileheaderbytes.Length + fi.Length + endBoundaryBytes.Length;
|
||||
|
||||
|
||||
httpWebRequest.BeginGetRequestStream(async (result) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)result.AsyncState;
|
||||
|
||||
using (Stream requestStream = request.EndGetRequestStream(result))
|
||||
{
|
||||
await WriteToStream(requestStream, boundarybytes, boundarybytes.Length);
|
||||
await WriteToStream(requestStream, fileheaderbytes, fileheaderbytes.Length);
|
||||
using (var fss = fi.OpenRead())
|
||||
{
|
||||
byte[] buffer = new byte[TXLEN];
|
||||
var form_bytes_read = fss.Read(buffer, 0, TXLEN);
|
||||
while (form_bytes_read > 0)
|
||||
{
|
||||
await WriteToStream(requestStream, buffer, form_bytes_read);
|
||||
form_bytes_read = fss.Read(buffer, 0, TXLEN);
|
||||
}
|
||||
}
|
||||
requestStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
|
||||
requestStream.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception rex)
|
||||
{
|
||||
report.Message = rex.Message;
|
||||
Console.Error.WriteLine(rex.Message);
|
||||
Console.Error.WriteLine("Stack trace:");
|
||||
Console.Error.WriteLine(rex.StackTrace);
|
||||
}
|
||||
}, httpWebRequest);
|
||||
|
||||
WebResponse resp = httpWebRequest.GetResponse();
|
||||
|
||||
Stream stream = resp.GetResponseStream();
|
||||
StreamReader re = new StreamReader(stream);
|
||||
if (resp is HttpWebResponse)
|
||||
{
|
||||
String json = re.ReadToEnd();
|
||||
report.Message = json;
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
report.OK = hrep.StatusCode == HttpStatusCode.Accepted
|
||||
|| hrep.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
else throw new Exception("Invalid server response type");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates HTTP POST request & uploads database to server. Author : Farhan Ghumra
|
||||
@ -22,7 +97,7 @@ namespace nuget_cli
|
||||
internal async Task UploadFilesToServerAsync(PushReport report, Uri uri, FileInfo fi,
|
||||
string apikey)
|
||||
{
|
||||
// string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
|
||||
// string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
|
||||
const int TXLEN = 0x1000;
|
||||
/// the form-data file upload, properly formatted
|
||||
string fileheaderTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\";\r\nContent-Type: {2}\r\n\r\n";
|
||||
@ -95,6 +170,7 @@ namespace nuget_cli
|
||||
|| hrep.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
else throw new Exception("Invalid server response type");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -13,6 +13,7 @@ using NuGet.Packaging.Core;
|
||||
using NuGet.Versioning;
|
||||
using isn.Data;
|
||||
using isn.Helpers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace isn.Controllers
|
||||
{
|
||||
@ -26,7 +27,7 @@ namespace isn.Controllers
|
||||
try
|
||||
{
|
||||
var clientVersionId = Request.Headers["X-NuGet-Client-Version"];
|
||||
var apiKey = Request.Headers["X-NuGet-ApiKey"];
|
||||
string apiKey = Request.Headers["X-NuGet-ApiKey"][0];
|
||||
ViewData["versionId"] = typeof(PackagesController).Assembly.FullName;
|
||||
var files = new List<string>();
|
||||
ViewData["files"] = files;
|
||||
@ -39,7 +40,7 @@ namespace isn.Controllers
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
foreach (var file in Request.Form.Files)
|
||||
foreach (IFormFile file in Request.Form.Files)
|
||||
{
|
||||
string initpath = Path.Combine(Environment.GetEnvironmentVariable("TEMP") ??
|
||||
Environment.GetEnvironmentVariable("TMP") ?? "/tmp",
|
||||
|
@ -86,7 +86,7 @@ namespace isn.Controllers
|
||||
}
|
||||
if (semVerLevel != defaultSemVer)
|
||||
{
|
||||
ModelState.AddModelError("semVerLevel", defaultSemVer + " expected");
|
||||
_logger.LogWarning("Unexpected sementic version : "+semVerLevel);
|
||||
}
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
@ -19,6 +19,7 @@ namespace isnd.Services
|
||||
int skip, int take,bool prerelease = false,
|
||||
string packageType = null)
|
||||
{
|
||||
|
||||
var scope = dbContext.Packages
|
||||
.Include(p => p.Versions)
|
||||
.Where(
|
||||
@ -26,11 +27,13 @@ namespace isnd.Services
|
||||
&& (prerelease || p.Versions.Any(v => !v.IsPrerelease))
|
||||
&& (packageType == null || p.Versions.Any(v => v.Type == packageType))
|
||||
);
|
||||
var total = scope.Count();
|
||||
var pkgs = scope.Skip(skip).Take(take).ToArray();
|
||||
|
||||
return new IndexResult
|
||||
{
|
||||
totalHits = scope.Count(),
|
||||
data = scope.OrderBy(p => p.Id)
|
||||
.Skip(skip).Take(take).ToArray()
|
||||
totalHits = total,
|
||||
data = pkgs
|
||||
};
|
||||
}
|
||||
public AutoCompleteResult AutoComplete (string id,
|
||||
|
19
src/isnd/packages/isn/1.0.0/isn.nuspec
vendored
Normal file
19
src/isnd/packages/isn/1.0.0/isn.nuspec
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>isn</id>
|
||||
<version>1.0.0</version>
|
||||
<authors>isn</authors>
|
||||
<description>Package Description</description>
|
||||
<dependencies>
|
||||
<group targetFramework=".NETFramework4.7.2">
|
||||
<dependency id="Mono.Options" version="5.3.0" exclude="Build,Analyzers" />
|
||||
<dependency id="Newtonsoft.Json" version="11.0.1" exclude="Build,Analyzers" />
|
||||
<dependency id="unleash.client" version="1.6.1" exclude="Build,Analyzers" />
|
||||
</group>
|
||||
</dependencies>
|
||||
<frameworkAssemblies>
|
||||
<frameworkAssembly assemblyName="System.Net.Http" targetFramework=".NETFramework4.7.2" />
|
||||
</frameworkAssemblies>
|
||||
</metadata>
|
||||
</package>
|
@ -1,4 +1,6 @@
|
||||
.body-container {
|
||||
|
||||
|
||||
.body-container {
|
||||
margin-top: 60px;
|
||||
padding-bottom:40px;
|
||||
}
|
||||
@ -38,5 +40,14 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// Your variable overrides
|
||||
$body-bg: #000;
|
||||
$body-color: #111;
|
||||
$theme-colors: (
|
||||
"primary": #0074d9,
|
||||
"danger": #ff4136
|
||||
);
|
||||
|
||||
@import "../lib/bootstrap/scss/bootstrap";
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user