{"id":113,"date":"2007-08-21T21:34:00","date_gmt":"2007-08-21T21:34:00","guid":{"rendered":"https:\/\/wdev-blog.azurewebsites.net\/index.php\/2007\/08\/21\/read-write-files-from-to-an-image-field-in-sql-server\/"},"modified":"2007-08-21T21:34:00","modified_gmt":"2007-08-21T21:34:00","slug":"read-write-files-from-to-an-image-field-in-sql-server","status":"publish","type":"post","link":"http:\/\/panahy.nl\/index.php\/2007\/08\/21\/read-write-files-from-to-an-image-field-in-sql-server\/","title":{"rendered":"Read\/Write files from\/to an Image field in SQL-Server"},"content":{"rendered":"<p>In this example I have a table called Attachment having a field of time Image which holds binary value. In this field I am going to put any type of file in a byte array and read it back. I have defined a class called Attachment to read and write the records. This class has a variable called Data which is defined as byte[]<\/p>\n<p><\/p>\n<h3>Read Image Field<\/h3>\n<p><span style=\"font-size:85%;\">This example passes a reference to an object called record of type Attachment. The record object has an attribute called Data where the attachment file will be streamed into it.<\/span><\/p>\n<p><\/p>\n<pre><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;summary&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> Read a TestLog record identified by the given parameter<br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;\/summary&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;param name=\"id\"&gt;<\/span><span style=\"color:#008000;\">the record key<\/span><span style=\"color:#808080;\">&lt;\/param&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;returns&gt;<\/span><span style=\"color:#008000;\">a Attachment object that maps to the record<\/span><span style=\"color:#808080;\">&lt;\/returns&gt;<\/span><span style=\"color:#808080;\"><br \/><\/span><span style=\"color:#0000ff;\">public<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">static<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">void<\/span><span style=\"color:#000000;\"> Read(Attachment record)<br \/>{<br \/><br \/><br \/>    <\/span><span style=\"color:#0000ff;\">if<\/span><span style=\"color:#000000;\"> (record.Id <\/span><span style=\"color:#000000;\">&lt;<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#ff0000;\">1<\/span><span style=\"color:#000000;\">)<br \/>        <\/span><span style=\"color:#0000ff;\">throw<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> ApplicationException(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">Invalid Record ID<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">);<br \/><br \/>    <\/span><span style=\"color:#0000ff;\">using<\/span><span style=\"color:#000000;\"> (SqlConnection sqlConnection1 <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> Connection)<br \/>    {<br \/>        SqlCommand cmd <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> sqlConnection1.CreateCommand();<br \/>        cmd.CommandType <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> CommandType.Text;<br \/>        cmd.CommandText <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">SELECT TestLogId, Name, Description, CreatedBy, CreateDate, Data FROM Attachment WHERE ID=@Id<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">;<br \/><br \/>        SqlParameter par <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> SqlParameter(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">@Id<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">, SqlDbType.Int);<br \/>        par.Value <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> record.Id;<br \/>        cmd.Parameters.Add(par);<br \/><br \/><br \/>        sqlConnection1.Open();<br \/>        SqlDataReader dr <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> cmd.ExecuteReader();<br \/>        <\/span><span style=\"color:#0000ff;\">if<\/span><span style=\"color:#000000;\"> (<\/span><span style=\"color:#000000;\">!<\/span><span style=\"color:#000000;\">dr.HasRows)<br \/>            <\/span><span style=\"color:#0000ff;\">throw<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> ApplicationException(String.Format(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">Could not find TestLog '{0}'.<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">, record.Id));<br \/><br \/>        dr.Read();<br \/><br \/>        <\/span><span style=\"color:#0000ff;\">if<\/span><span style=\"color:#000000;\"> (<\/span><span style=\"color:#000000;\">!<\/span><span style=\"color:#000000;\">dr.IsDBNull(<\/span><span style=\"color:#ff0000;\">0<\/span><span style=\"color:#000000;\">))<br \/>            record.TestLogID <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> dr.GetInt32(<\/span><span style=\"color:#ff0000;\">0<\/span><span style=\"color:#000000;\">);<br \/>        <\/span><span style=\"color:#0000ff;\">if<\/span><span style=\"color:#000000;\"> (<\/span><span style=\"color:#000000;\">!<\/span><span style=\"color:#000000;\">dr.IsDBNull(<\/span><span style=\"color:#ff0000;\">1<\/span><span style=\"color:#000000;\">))<br \/>            record.Name <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> dr.GetString(<\/span><span style=\"color:#ff0000;\">1<\/span><span style=\"color:#000000;\">).TrimEnd();<br \/>        <\/span><span style=\"color:#0000ff;\">if<\/span><span style=\"color:#000000;\"> (<\/span><span style=\"color:#000000;\">!<\/span><span style=\"color:#000000;\">dr.IsDBNull(<\/span><span style=\"color:#ff0000;\">2<\/span><span style=\"color:#000000;\">))<br \/>            record.Description <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> dr.GetString(<\/span><span style=\"color:#ff0000;\">2<\/span><span style=\"color:#000000;\">).TrimEnd();<br \/>        <\/span><span style=\"color:#0000ff;\">if<\/span><span style=\"color:#000000;\"> (<\/span><span style=\"color:#000000;\">!<\/span><span style=\"color:#000000;\">dr.IsDBNull(<\/span><span style=\"color:#ff0000;\">3<\/span><span style=\"color:#000000;\">))<br \/>            record.CreatedBy <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> dr.GetString(<\/span><span style=\"color:#ff0000;\">3<\/span><span style=\"color:#000000;\">).TrimEnd();<br \/>        <\/span><span style=\"color:#0000ff;\">if<\/span><span style=\"color:#000000;\"> (<\/span><span style=\"color:#000000;\">!<\/span><span style=\"color:#000000;\">dr.IsDBNull(<\/span><span style=\"color:#ff0000;\">4<\/span><span style=\"color:#000000;\">))<br \/>            record.CreateDate <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> dr.GetDateTime(<\/span><span style=\"color:#ff0000;\">4<\/span><span style=\"color:#000000;\">);<br \/><br \/>        <\/span><span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\"> Read the bytes into the Data attribute of the record<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#000000;\">        <\/span><span style=\"color:#0000ff;\">int<\/span><span style=\"color:#000000;\"> PictureCol <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#ff0000;\">5<\/span><span style=\"color:#000000;\">; <\/span><span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\"> the column # of the BLOB field                    <\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#000000;\">        record.Data <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> Byte[(dr.GetBytes(PictureCol, <\/span><span style=\"color:#ff0000;\">0<\/span><span style=\"color:#000000;\">, <\/span><span style=\"color:#0000ff;\">null<\/span><span style=\"color:#000000;\">, <\/span><span style=\"color:#ff0000;\">0<\/span><span style=\"color:#000000;\">, <\/span><span style=\"color:#0000ff;\">int<\/span><span style=\"color:#000000;\">.MaxValue))];<br \/>        dr.GetBytes(PictureCol, <\/span><span style=\"color:#ff0000;\">0<\/span><span style=\"color:#000000;\">, record.Data, <\/span><span style=\"color:#ff0000;\">0<\/span><span style=\"color:#000000;\">, record.Data.Length);<br \/>     <br \/>        dr.Close();<br \/>        sqlConnection1.Close();<br \/>    }<br \/>}<\/span><\/pre>\n<p><\/p>\n<h3>Write File into the record<\/h3>\n<pre><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;summary&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> Save the Attachment record. If Id doesn't exist, it will create a new one, otherwise it will update.<br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;\/summary&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;param name=\"record\"&gt;<\/span><span style=\"color:#008000;\">the attachment record to save<\/span><span style=\"color:#808080;\">&lt;\/param&gt;<\/span><span style=\"color:#808080;\"><br \/><\/span><span style=\"color:#0000ff;\">public<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">static<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">void<\/span><span style=\"color:#000000;\"> Save(Attachment record)<br \/>{<br \/><br \/>    <\/span><span style=\"color:#0000ff;\">using<\/span><span style=\"color:#000000;\"> (SqlConnection sqlConnection1 <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> Connection)<br \/>    {<br \/>        SqlCommand cmd <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> sqlConnection1.CreateCommand();<br \/>        cmd.CommandType <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> CommandType.StoredProcedure;<br \/>        cmd.CommandText <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">SaveAttachment<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">;<br \/><br \/>        <\/span><span style=\"color:#0000ff;\">#region<\/span><span style=\"color:#000000;\"> Add the input parameter and set its value<\/span><span style=\"color:#000000;\"><br \/><br \/>        SqlParameter par <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> SqlParameter(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">@TestLogId<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">, SqlDbType.Int);<br \/>        par.Value <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> record.TestLogID;<br \/>        cmd.Parameters.Add(par);<br \/><br \/>        par <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> SqlParameter(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">@Name<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">, SqlDbType.NVarChar, <\/span><span style=\"color:#ff0000;\">128<\/span><span style=\"color:#000000;\">);<br \/>        par.Value <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> record.Name;<br \/>        cmd.Parameters.Add(par);<br \/><br \/>        par <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> SqlParameter(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">@Description<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">, SqlDbType.NVarChar, <\/span><span style=\"color:#ff0000;\">320<\/span><span style=\"color:#000000;\">);<br \/>        par.Value <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> record.Description;<br \/>        cmd.Parameters.Add(par);<br \/><br \/>        par <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> SqlParameter(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">@Data<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">, SqlDbType.VarBinary, record.Data.Length);<br \/>        par.Value <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> record.Data;<br \/>        cmd.Parameters.Add(par);<br \/><br \/>        <\/span><span style=\"color:#0000ff;\">#endregion<\/span><span style=\"color:#000000;\"><br \/><br \/>        <\/span><span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\"> Add the output parameter <\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#000000;\">        par <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> SqlParameter(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">@Id<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">, SqlDbType.Int, <\/span><span style=\"color:#ff0000;\">4<\/span><span style=\"color:#000000;\">);<br \/>        par.Direction <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> ParameterDirection.InputOutput;<br \/>        par.Value <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> record.Id;<br \/>        cmd.Parameters.Add(par);<br \/><br \/>        sqlConnection1.Open();<br \/>        cmd.ExecuteNonQuery();<br \/>        <\/span><span style=\"color:#0000ff;\">int<\/span><span style=\"color:#000000;\"> id <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> Int32.Parse(cmd.Parameters[<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">@ID<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">].Value.ToString());<br \/>        record.Id <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> id;<br \/>        sqlConnection1.Close();<br \/>    }<br \/>}<\/span><\/pre>\n<p><\/p>\n<h3>Read the file into the variable<\/h3>\n<p><\/p>\n<pre><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;summary&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> Read the file into the Data field<br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;\/summary&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;param name=\"path\"&gt;<\/span><span style=\"color:#008000;\">A valid path to the file<\/span><span style=\"color:#808080;\">&lt;\/param&gt;<\/span><span style=\"color:#808080;\"><br \/><\/span><span style=\"color:#0000ff;\">public<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">void<\/span><span style=\"color:#000000;\"> ReadFromFile(<\/span><span style=\"color:#0000ff;\">string<\/span><span style=\"color:#000000;\"> path)<br \/>{<br \/>    System.IO.FileStream fs <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"><br \/>        <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read);<br \/><br \/>    <\/span><span style=\"color:#0000ff;\">this<\/span><span style=\"color:#000000;\">.data <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> Byte[fs.Length];<br \/>    fs.Read(<\/span><span style=\"color:#0000ff;\">this<\/span><span style=\"color:#000000;\">.data, <\/span><span style=\"color:#ff0000;\">0<\/span><span style=\"color:#000000;\">, <\/span><span style=\"color:#0000ff;\">this<\/span><span style=\"color:#000000;\">.data.Length);<br \/>    fs.Close();<br \/>}<\/span><\/pre>\n<h3>Write the byte array to a File<\/h3>\n<p>This simple method is using the name of the file as is stored in the attachment record to save in the location specified by parameter.<\/p>\n<p><\/p>\n<pre><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;summary&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> Save the content into a file<br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;\/summary&gt;<\/span><span style=\"color:#008000;\"><br \/><\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\"> <\/span><span style=\"color:#808080;\">&lt;param name=\"path\"&gt;<\/span><span style=\"color:#008000;\">the full path to write to<\/span><span style=\"color:#808080;\">&lt;\/param&gt;<\/span><span style=\"color:#808080;\"><br \/><\/span><span style=\"color:#0000ff;\">public<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">void<\/span><span style=\"color:#000000;\"> SaveToFile(<\/span><span style=\"color:#0000ff;\">string<\/span><span style=\"color:#000000;\"> path)<br \/>{<br \/>    <\/span><span style=\"color:#0000ff;\">if<\/span><span style=\"color:#000000;\"> (path.EndsWith(<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">\\<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">))<br \/>        path <\/span><span style=\"color:#000000;\">+=<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#008080;\">\\<\/span><span style=\"color:#000000;\">\"<\/span><span style=\"color:#000000;\">;<br \/><br \/>    <\/span><span style=\"color:#0000ff;\">string<\/span><span style=\"color:#000000;\"> DestFilePath <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"> path <\/span><span style=\"color:#000000;\">+<\/span><span style=\"color:#000000;\"> <\/span><span style=\"color:#0000ff;\">this<\/span><span style=\"color:#000000;\">.name;<br \/>    System.IO.FileStream fs <\/span><span style=\"color:#000000;\">=<\/span><span style=\"color:#000000;\"><br \/>             <\/span><span style=\"color:#0000ff;\">new<\/span><span style=\"color:#000000;\"> System.IO.FileStream(DestFilePath, System.IO.FileMode.Create, System.IO.FileAccess.Write);<br \/><br \/>    fs.Write(<\/span><span style=\"color:#0000ff;\">this<\/span><span style=\"color:#000000;\">.data, <\/span><span style=\"color:#ff0000;\">0<\/span><span style=\"color:#000000;\">, <\/span><span style=\"color:#0000ff;\">this<\/span><span style=\"color:#000000;\">.data.Length);<br \/>    fs.Close();<br \/><br \/>}<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this example I have a table called Attachment having a field of time Image which holds binary value. In this field I am going to put any type of file in a byte array and read it back. I have defined a class called Attachment to read and write the records. This class has &hellip; <a href=\"http:\/\/panahy.nl\/index.php\/2007\/08\/21\/read-write-files-from-to-an-image-field-in-sql-server\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Read\/Write files from\/to an Image field in SQL-Server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"Pouya Panahy","author_link":"http:\/\/panahy.nl\/index.php\/author\/pouya\/"},"uagb_comment_info":0,"uagb_excerpt":"In this example I have a table called Attachment having a field of time Image which holds binary value. In this field I am going to put any type of file in a byte array and read it back. I have defined a class called Attachment to read and write the records. This class has&hellip;","_links":{"self":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/113"}],"collection":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":0,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/113\/revisions"}],"wp:attachment":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/media?parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/categories?post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/tags?post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}