<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Keyur Gohil on Medium]]></title>
        <description><![CDATA[Stories by Keyur Gohil on Medium]]></description>
        <link>https://medium.com/@keyurgohil22?source=rss-e00b230d2231------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ua7MCxpT3cz0DqU0M6OSiw.jpeg</url>
            <title>Stories by Keyur Gohil on Medium</title>
            <link>https://medium.com/@keyurgohil22?source=rss-e00b230d2231------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 08:21:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@keyurgohil22/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Upload an image to the database as a blob using Angular and c#]]></title>
            <link>https://medium.com/@keyurgohil22/upload-an-image-to-the-database-as-a-blob-using-angular-and-c-1e8f8cc1dbd6?source=rss-e00b230d2231------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e8f8cc1dbd6</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[blob]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[image-upload]]></category>
            <dc:creator><![CDATA[Keyur Gohil]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 12:36:11 GMT</pubDate>
            <atom:updated>2023-05-13T10:34:52.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mKo3biuPjCPQgAcEzFkHpQ.png" /></figure><p>Uploading an image to a database as a <strong>BLOB</strong> using <strong>Angular</strong> and <strong>C#</strong> involves a few steps. First, you must create a form allowing users to select an image file. Then, you must handle the form submission and convert the file data to a BLOB. Finally, you need to send the BLOB to the server, save it to the database using C#, and return a response to the client.</p><p>Here is an example of how you can upload an image to a database as a BLOB using Angular and C#:</p><ol><li>Create a form that allows users to select an image file:</li></ol><pre>&lt;form (submit)=&quot;onSubmit()&quot;&gt;<br>  &lt;input type=&quot;file&quot; (change)=&quot;onFileSelected($event)&quot;&gt;<br>  &lt;button type=&quot;submit&quot;&gt;Upload&lt;/button&gt;<br>&lt;/form&gt;</pre><p>2. Handle the form submission and convert the file data to a BLOB:</p><pre>import { Component } from &#39;@angular/core&#39;;<br>import { HttpClient } from &#39;@angular/common/http&#39;;<br><br>@Component({<br>  selector: &#39;app-upload&#39;,<br>  templateUrl: &#39;./upload.component.html&#39;,<br>  styleUrls: [&#39;./upload.component.css&#39;]<br>})<br>export class UploadComponent {<br><br>  selectedFile: File;<br><br>  constructor(private http: HttpClient) { }<br><br>  onFileSelected(event): void {<br>    this.selectedFile = event.target.files[0];<br>  }<br><br>  onSubmit(): void {<br>    const reader = new FileReader();<br>    reader.readAsArrayBuffer(this.selectedFile);<br>    reader.onload = () =&gt; {<br>      const blob = new Blob([reader.result], { type: this.selectedFile.type });<br>      this.uploadImage(blob);<br>    };<br>  }<br><br>  uploadImage(blob: Blob): void {<br>    const formData = new FormData();<br>    formData.append(&#39;image&#39;, blob, this.selectedFile.name);<br>    this.http.post(&#39;/api/upload&#39;, formData).subscribe(<br>      (response) =&gt; console.log(response),<br>      (error) =&gt; console.log(error)<br>    );<br>  }<br><br>}</pre><p>3. Send the BLOB to the server and save it to the database using C#:</p><pre>using System.IO;<br>using System.Net;<br>using System.Net.Http;<br>using System.Web.Http;<br><br>public class UploadController : ApiController<br>{<br>    public HttpResponseMessage Post()<br>    {<br>        var httpRequest = HttpContext.Current.Request;<br>        if (httpRequest.Files.Count &gt; 0)<br>        {<br>            var file = httpRequest.Files[0];<br>            using (var binaryReader = new BinaryReader(file.InputStream))<br>            {<br>                byte[] fileData = binaryReader.ReadBytes(file.ContentLength);<br>                var image = new Image<br>                {<br>                    Name = file.FileName,<br>                    Data = fileData,<br>                    ContentType = file.ContentType<br>                };<br>                using (var dbContext = new MyDbContext())<br>                {<br>                    dbContext.Images.Add(image);<br>                    dbContext.SaveChanges();<br>                }<br>            }<br>            return Request.CreateResponse(HttpStatusCode.OK, &quot;Uploaded&quot;);<br>        }<br>        else<br>        {<br>            return Request.CreateResponse(HttpStatusCode.BadRequest);<br>        }<br>    }<br>}</pre><p>4. Define a model for the image data:</p><pre>public class Image<br>{<br>    public int Id { get; set; }<br>    public string Name { get; set; }<br>    public byte[] Data { get; set; }<br>    public string ContentType { get; set; }<br>}</pre><p>5. Define a DbContext for the database:</p><pre>using System.Data.Entity;<br><br>public class MyDbContext : DbContext<br>{<br>    public DbSet&lt;Image&gt; Images { get; set; }<br>}</pre><p>This code assumes that you have created a database using Entity Framework Code First and created a table for storing image data as a BLOB. When the form is submitted, the file data is read as a byte array using a BinaryReader. The byte array is then saved to the database using Entity Framework, and a response</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e8f8cc1dbd6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to integrate Visual Studio Team Services with Visual Studio Code Editor?]]></title>
            <link>https://medium.com/@keyurgohil22/how-to-integrate-visual-studio-team-services-with-visual-studio-code-editor-fb60008f7305?source=rss-e00b230d2231------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb60008f7305</guid>
            <category><![CDATA[vsts]]></category>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[vs-team-services]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[clone-vsts]]></category>
            <dc:creator><![CDATA[Keyur Gohil]]></dc:creator>
            <pubDate>Mon, 23 Jul 2018 18:13:38 GMT</pubDate>
            <atom:updated>2023-05-13T10:35:29.839Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JPGRBZZUlvGUpMWHlilEQQ.png" /></figure><p>We decide to use Visual Studio Code Editor for the project that is already maintain on Visual Studio Team Services. So need to configure our code with Visual Studio Code editor.</p><p>Here are the steps to clone code from Visual Studio Team Services to Visual Studio Code.</p><blockquote>Prerequisite Install Visual Studio Code, Install git bash.</blockquote><ol><li>Add Extensions to Visual Studio Code</li><li>Create personal access token</li><li>Clone Project</li><li>Configure Visual Studio Code with Personal Access Token</li></ol><h3><strong>Add Extensions to </strong>Visual Studio<strong> Code</strong></h3><p>Open Visual Studio Code and go to Extension: Marketplace by pressing Ctrl+Shift+X. We need to install two extensions</p><p><strong>I. </strong>Write<strong><em> </em></strong><em>Visual Studio Team Services </em>and click on install. Once it installed successfully click on Reload.</p><p><strong>II<em>. </em></strong>Write<strong><em> </em></strong><em>PowerShell </em>and click on install. Once it installed successfully click on Reload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9CRUvH5tx-IWrYCupNM0HA.png" /></figure><h3><strong>Create personal access token</strong></h3><p>Now open your project on Visual Studio Team Services go to Security from clicking on top right profile picture.</p><p>Click on add button and give description, select Expires in, select organisation and select Authorized scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pntsL_iA-S4hqcPgiR5z8Q.png" /></figure><p>Now click on Create Token at bottom of the form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eMS-ilIMf8ZCWNFkv1yalg.png" /></figure><p><strong>Note:</strong> Now you can see your new Personal access token created and it will show you one message “Make sure you cope the token now. We don’t store it and you won’t be able to see it again.” , So here we need to copy our token and keep it safe like it is password for us.</p><h3>Clone Project</h3><p>First go to Visual Studio Team Services, go to code and copy link to clone the project.</p><p>Then go to location on your location machine where you want to clone the project. Right click and select <em>Git Bash here </em>and use command below</p><pre>git clone &lt;Paste you link here&gt;</pre><p>Before cloning code it will ask for login, so simply provide your credential.</p><h3>Configure Visual Studio Code with Personal Access Token</h3><p>Once the project is cloned successfully, Open Visual Studio Code and open folder of your newly cloned project.</p><p>Now press F1 key and write Team: Signin and press enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d8uRe_fi6kIT8_WPz_zVCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*ItKpAtENGe-pkLBFpIRcOg.png" /></figure><p>Here it will provide two method to access this Token either via access token or via authentication. We will go with first option access token so select that and press enter.</p><p>Now we need our access token that we copied while token created and paste it in the same box and press enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*M12ZkTnLRnknIob-l8wLow.png" /></figure><p>Now you can see at bottom it’s show branch name.</p><p>That’t it! Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb60008f7305" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>