Is there any way I can query the image from SalesForce server as a blob object ?
We already have forcetk client queries which is retrieving all the data, but the image alone is returned as a link (salesforce link).
Can we retrieve image as blob in the same REST query call ?
The methods I saw required to make an extra call to fetch images, but here I have images in each row of the result, it would have been better if images come as a part of result object itself.
If you're using the REST API, then the blob data can't be returned with the rest of the object, it has to be a separate request. If you use SOAP then it can inline the blob data with the rest of the fields for the object, but it will be limited to returning one row at a time.
Related
My problems here is that they are loading the data from an external resource which return JSON, instead of this I want to know how can we give our own internal JSON data which is there in a variable as a URL parameter
I know that blob is a data type for binary data as integer is a datatype for int. As they say, It's used to store files directly in database (we move our audio file into blob, and save that blob in database).
Question 1) why to store blob for audio if I can just put the audio in storage for example path /var/www/audio.mp3 and in database I store path_name /var/www/audio.mp3?
Question 2) which is better ? how netflix stores movies? just blobs or what?
Question 3) Curious if there're any cons or prons if you could just give me ideas so that I know when to use them .
Putting the blob in the database, rather than a file, allows you to grow to multiple servers with load balancing. If you put the data in files, you would have to replicate the files between the server. Most databases have built-in replication features, this isn't as easy for regular files.
Better to use external storage/cdn for serving such kind of large content.
How Netflix and our works? They upload content on external bucket i. e. S3 and write file name in db for identification. According to user file access frequency that file cache on CDN/edge location. User will get awesome experience while content server from their nearest edge location
With blob you can store all kinds of stuff.
Do you communicate with an API via SOAP or JSON and want to store it in the database? Use a blob. Want to log what a user filled into a form when it threw an exception? Store the entire post as a blob. You can save everything as is. It's handy for logging if you have different data formats. I know an API which expects some data via SOAP and some as JSON. To log the communication I use blob because the response may be in XML, JSON, a number (http code 203 for empty but accepted) or an exception as array.
Basically, this app should contain a collection of objects in a view showing a representative image of each object (i.e. a movie should show its poster).
Talking about movies, I am trying to use the IMDB APIs in order to retrieve the metadata for a certain movie title, including its poster. However, hotlinking won't let me display the images once their URLs are obtained from the APIs (I keep getting the "GET [...] 403 Forbidden" error...).
Since I am using the JSONStore feature in order to cache the data, I would like to know if there is a possibility to store those images in JSONStore and then display them like a normal browser would do. I am trying to do all this sort of things from the front-end side, not the back-end one, using AngularJS, HTML5 and JavaScript.
Do you have any suggestions for this kind of problems?
Thank you.
Suggested solution: What you'd need to do is to encode the images to base64 and this way you could store the binary image as a string inside your JSONStore collection.
When you then need to display it you will need to base64 decode the string back into an image and display it in your HTML
I'm using jsOauth-twitter to upload an image to twitter which calls the update_with_media api method. It looks like it needs the actual image data. This is already on my webpage inside a normal <img src="localfile"> tag.
Using Javascript, can I get at the actual image data (JPEG) to pass it to the function? Is it available in the DOM? I need the raw image data so I can pass it to twitter as application/octet-stream, so base64 is no good to me.
It looks like the API requires the form to be sent as multipart/form-data, which means the media[] parameter is expecting a file rather than binary or base64 encoded data. If you use HTML file input inside a form, this should be fairly straightward.
If you must use the <img> tag, then it would be difficult. All I can think of is draw the image to a <canvas>, obtain a base64-encoded URI with toDataURI(), decode it to obtain the raw image data using window.atob(), then build the multipart/form-data POST body manually. This answer has some sample code for the first couple of things.
The Blob API may help in creating a file-like object which your OAuth library can accept (rather than manually building the request body), but its not very well supported yet.
The situation is that you have to work with an image API and you have to make a POST request to get an image stream that you want to display in the rest of your web page.
I can make an ajax request to that service on page load using jQuery, but i just get a binary stream returned. Is there anyway that JavaScript can take that binary string and display the content type that is in the header?
I believe what you are looking for is that Data URI Scheme - which allows you to format a really long URI that specifies the needed binary data in itself.
I believe you'll need to arrange to have the stream delivered when a URL is referenced by an HTTP GET operation - then have JavaScript set the src attribute of the image to that URL. I've seen this done with ASP.NET, where a .ashx handler is used to stream the image. One then references http://site.com/images/imagehandler.ashx?parameters.
Can you not set an image's src attribute to the url you are using for your ajax communication currently? Or do you have to strip out other info from the ajax call first?
do form post request with targeting an iframe. this is the only way.
Just use javascript to create an img element with the url that returns the image as the src:
// jquery
$(#some-id).append('<img src="/get-image/?foo=bar"/>');