Posts

Showing posts with the label Blob

BLOB To String, SQL Server

Answer : Problem was apparently not the SQL server, but the NAV system that updates the field. There is a compression property that can be used on BLOB fields in NAV, that is not a part of SQL Server. So the custom compression made the data unreadable, though the conversion worked. The solution was to turn off compression through the Object Designer, Table Designer, Properties for the field (Shift+F4 on the field row). After that the extraction of data can be made with e.g.: select convert(varchar(max), cast(BLOBFIELD as binary)) from Table Thanks for all answers that were correct in many ways! The accepted answer works for me only for the first 30 characters. This works for me: select convert(varchar(max), convert(varbinary(max),myBlobColumn)) FROM table_name It depends on how the data was initially put into the column. Try either of these as one should work: SELECT CONVERT(NVarChar(40), BLOBTextToExtract) FROM [NavisionSQL$Customer]; Or if it was just varchar ... ...

Angular: How To Download A File From HttpClient?

Answer : Blobs are returned with file type from backend. The following function will accept any file type and popup download window: downloadFile(route: string, filename: string = null): void{ const baseUrl = 'http://myserver/index.php/api'; const token = 'my JWT'; const headers = new HttpHeaders().set('authorization','Bearer '+token); this.http.get(baseUrl + route,{headers, responseType: 'blob' as 'json'}).subscribe( (response: any) =>{ let dataType = response.type; let binaryData = []; binaryData.push(response); let downloadLink = document.createElement('a'); downloadLink.href = window.URL.createObjectURL(new Blob(binaryData, {type: dataType})); if (filename) downloadLink.setAttribute('download', filename); document.body.appendChild(downloadLink); downloadLink.click(); }...