I'm making a iOS game which will pick a random clue(text) and image (clue and image come in a set, 1 row) from the clue repository in the database. I have a web service with webMethods and functions that allow me to pull the database row out. (tested for clue) I've been searching on Google for articles on how to import image to iOS from db but to no avail.
how to import image from DB by web service (build using c#)? Can anyone please guide me in the right direction? I would like it to be stored in mutableArray so that after the player are done playing, the clue and image will be wipe off the temp array. (i don't want to put the image in the app as that will make the app very large and that user are able to upload their own clues and image, so live feed from database is the ideal method.
Right now I'm stuck on the web service side on importing the image over. I'm currently using List to store the clue, but have no idea on what to use to store image. I am thinking of using ArrayList which store object, but have no idea how to convert it to image at the iOS side. And as I mentioned above, I can't seem to find any tutorial or example that import image to iOS app via web service. (or am I using the wrong search term)
Will be helpful if any1 can help me out, or give alternate solution which enable live update of image and clues.
EDIT - I found ImageList() and List. which one should I be using now?
Also found out to make image file is just -> image testfile;
EDIT2 - problem I'm facing
-dealing with image file (image? imagelist?
-when drawing datarow from DB in webservice, how do i deal with the image file. (guessing ImageList or List<image> (after some luck on research)
-assuming 2nd point works fine, i should be able to solve the client side
(sorry, noobie at webservice, )
.
what I have
-webservice that draw datarow from database for clue(string) (tested and working fine with my function)
-iOS client side with RESTful architecture
.
what I need
-webservice that draw datarow from database for picture(image (format not so important yet)) (code should be similar to drawing clue, only which function to store it in. (using List<string> for clues)
Sounds like you might be getting a bit ahead of yourself. Try solving just one problem at a time; you'll make much more progress.
First, do you know how to download an image to your iOS application? Try downloading a very simple publicly available image like a Google doodle: https://www.google.com/logos/2012/gymnastics-2012-hp.jpg. Whatever IOS application toolkit you're using should have a walkthrough for how to download an image and present it via HTTP.
Second, do you know how to host an image file on your web server? Try downloading a random JPG or PNG image yourself and hosting it on your server as a static file. Then point your IOS application at that static file and download it just like you did with the Google doodle.
If both of those steps work, you can then begin to host dynamic images on your server. Create a page (if you're using ASP.NET) or a controller path (if you're using MVC) and have your C# code use Response.TransmitFile to upload an image to the clickstream. Again, download that image to your IOS application to verify it worked.
Finally, modify your server application to take a parameter - either by a querystring (example: myhost.com/mypage.aspx?image_id=1) or by an MVC path (example: myhost.com/images/1). Use that ID number to retrieve the image information from your database. Then transmit the image to the client. If all goes well, you should then be able to retrieve this image in your IOS app.
I hope this helps you get closer to your project!
I have no experience programming on iOS, but I think that the easiest way is to prepare RESTful api for that. With the REST guidelines in mind, what you end up with is a webservice that defines a resource, and your client needs only to request a particular file (I assume that client somehow knows what the id/name of the image is). This has one big advantage - it is very easy to develop (on any platform) - server side.
When it comes to client side:
1. Use WebRequest object to create a http get request
2. Wait for the data to be downloaded (you may use background worker or just another thread, so that your app is not blocked)
3. When request is complete and you get the response object - read what was sent. It is going to be binary image.
4. Use the binary data (image) and display it in your app.
A sample of how to use WebRequest object is provided by me in different SO thread: https://stackoverflow.com/a/11891240/165751
Note: I assume you know how to retrieve the image from the DB (or any kind of store actually) on your server side so that your webservices can read it and return it as a webresponse.
There are plenty of possibilities when it comes to server side technology, but if you want to stay with .Net technology stack - I suggest to have a look at WCF REST Service Template 40(CS) - I've been using it in the past (and my service was returning images as well :) and I was very happy with it.
Related
I am a little confused as to how I should be handling image files in my project structure.
I have a workspace with a React app folder and a Web Api folder. The web api is for video games, and one of the fields in the model is a string, called image. I.e image: ‘call_of_duty_cover.jpg’
.
The thing is, we just learned how to upload images to web api, where we was taught to uplod into MyWebApi/wwwroot/images
But while doing some research I came across
a post here on Stack Overflow from 2017: Where should I store images in my web app?
Typically, you'll store images for your website in a directory called "imgs" underneath your root htdocs or public directory. This is considered the front end; you don't really store images in a backend or DB unless you're storing links to those images and providing those links via an API call.
If you wind up with lots of images, it's common to create more folders under that "imgs" directory, say one for each page or for one for each feature, but that's usually where images are kept.
So Im just confused as to why my lecturer would recommend using the wwwroot/images/ as source folder for imagefiles references with links in webapi?
And how would you guys recommend doing this? Thx
Edit: To clarify, the lecture I had the other day about image uploads was about how to upload images to webapi/wwwroot/images folder though React frontend— this is NOT what im asking today, I’m wondering in general where the image files that I reference in the webapi should be stored :) currently I have all the image files in the react project, under public/images/ :)
Edit 2:
So the project is to create a web api and database for different video games. And use react to make an interactive solution where one can play around with, I was thinking of doing a quiz thing. In the quiz, for every question I will need to fetch an image or an image link from the webapi to display the image. So I assume I store it somewhere in the folder structure and store strings of matching paths/filenames to fetch the images that way.
I will probably store 50+ games in the database :)
For static images that are part of the application you can have them in the React application in /public/images/.
For images uploaded by users you can store these images on the backend in /wwwroot/images/ on the backend API server.
You could also have the backend API upload images to a a dedicated content server or a content delivery network (CDN).
I have a situation where I need to display an image to an end user following the below method.
When the user request the image from a URL, the C# code behind should start by looking in an azure blob/cdn to see if the image is there. If the image is there and less than x days old, it should pass the image to the end user in the most efficient way (preferably without spending too many resources (memory & cpu) passing it to the user.
If the image is not there or more than a week old, the image will be generated based on the parameters supplied in the url the user requested, after which it is stored on the blob/cdn and displayed to the end user.
My problem is how, I in the most efficient way on azure, can generate a lot of images simultaneously as well as being able to pass the data from the cdn while still being able to first check if it is too "old" and needs to be regenerated or if it isn't there and needs to be generated before being displayed to the user. Since the second I pass the image through the c# code will loose the cdn's strengths.
There are many ways to do things on azure. You will need to look through the extensive azure documentation and determine what will best fit your needs.
If you want to get something working quickly azure blobs can be served directly to a client (straight to their browser) - see the doco keep in mind anonymous access is not secure.
How can I get Picture Previews to work with IE 8 and up?
Can I get binary image data from an input type "file", with JavaScript/jQuery?
If I can just get the data (in the right format) back to the server, I should be able to work with it there, and then return it with AJAX (although, I am absolutely no AJAX expert).
There is, according to the research that I have done, NO WAY to get picture previews in all IE versions using only javascript (this is because getting the full file path is seen, by them, as a potential security risk). I could ask my users to add the site to the trusted sites, but you don't usually ask users to tamper with those kinds of low-level settings (not to mention the quickest way to make your site seem suspicious to users is to ask them to directly add your site to the trusted sites list. That's like sending an email and asking for a password. "Just trust me! I'm soooo safe!" :)
I have picture previews working in everything except IE and have no problem using conditional comments to separate an IE specific way of doing this from the way I am doing it with other browsers. In other words, the answer doesn't even have to be cross-browser, just cross-IE (8 and 9). I know I have seen IE sites use picture previews before (somehow), so I know there must be at least ONE way to do this...
So if you need to support IE lower than 10 you could upload the file to the server using some of the existing AJAX upload components (Uploadify, Plupload, Valums AJAX Upload, Bleuimp, ...), generate and store a thumbnail on the server and send the url to the saved image to the client using JSON so that it could display it using an tag. Actually since IE supports Data URI Scheme you don't need to store the uploaded file to the server in order to generate the preview. You could directly return the resulting thumbnail image from your Preview controller action formatted as Data URI Scheme so that you could show it on the client.
Another solution if you don't have the time and resources to implement this functionality is to simply tell your users that if they want to get a realtime preview of the image that they should consider using a different web browser because your site doesn't support IE for this.
I'm developing a web (using asp.net and c#) which has a FileUpload control from asp.net. The upload thing works perfect and as far as I know I can't show progress data (%, bytes transfered, upload speed, time elapsed, time left, progress bar) using the FileUpload control from asp.net because its not asyncrhonous.
I've searched a lot (really) on the internet and I didn't find what i'm looking for and too much info has become a big confusion since I'm not sure about what I have to use.
On my web page I have a file named "UploadFile.aspx" which has a FileUpload control and a button that handles the uploading. On code-behind (UploadFile.aspx.cs) I have all the server-side logic (Upload the file into specific folder, store info about that file into a database, etc. etc) and I don't want to change this.
What I need to know is how to show the progress data to the user while is uploading the file? I can't use 3rd party applications because this is for an important commercial site. It's not a problem for me if I have to learn javascript / jQuery / Whatever but really i'm a bit lost and I don't know how to start.
Thanks for your time and your help guys.
There's some pretty cool solutions out there. Granted, you can code your own, but I'd suggest using a jQuery plugin like Plupload. If you need help setting it up, you can read their documentation.
There are lots of lots of demo code are available on the net to show the progress bar with file upload control in c#, most of them work fine on Local system but never work on the live server, Because You CAN'T USE A FileUpload control for what you want to do. When a user POSTs a file, you have to think of it like a querystring parameter. It goes as one Http Request. If you want to do a progress bar you'll want to look into something that can interact with the server asynchronously.
If you don't want to use any 3rd party that relies on Flash / Html 5, please take a look at this article:
http://vanacosmin.ro/Articles/Read/AjaxFileUpload
This is possible (and if you're using .NET 4.5 GetBufferedInputStream will make your life easier), but it is not very easy, as you'll see.
Basically, if you want a file upload with progress bar that is fully compatible with every browser, you need to handle this server side and give an url where the client (the browser) can check periodically for the progress with ajax.
I would like to have a lot of data (quotes of famous people, arround 100 k quotes). And I want that users are able to search, sort on category and sort on authors.
Got a big big xml file at the moment, but what is smart to do? How can i get all the quotes in the app? maybe a sql lite database? or just loop the xml when app starts?
Any tips are most welcome!
Kevin
UPDATE: Thanks for all the replies and tips, I really appreciate it and I am looking forward to program my App, did make a runkeeper-like app yesterday, now starting the quotes app.
I would recommend storing this data on a webserver somewhere and using some SOAP interface of something like this, to access it. I wouldn't be positively surprised when a downloaded application all of a sudden decides to download a big file of quotes.
I would recommend a SQL CE database (.sdf file)
Great overview here: http://windowsphonegeek.com/tips/Windows-Phone-Mango-Local-Database%28SQL-CE%29-Introduction
And here: http://msdn.microsoft.com/en-us/library/hh202860%28v=VS.92%29.aspx
There's no SQLite on WP7. There's SQL Server Compact though. Read up on the latter, and also on LINQ. WP7.5 only.
Alternatively, store data on the Web server, and use a service to pull it on demand. In that case, read up on services and SOAP.
With the fact that you are looking at a 500mb file I think you have a couple of options.
1) Put all of this data in a database on a webserver, then have your phone application use whatever method you like to contact the database to get specific data that is needed. Obviously your UI would have to be optimised to allow a user to sort by the type of quote and / or the person to whom the quote is attributed.
2) If you want this to be done without the use of the webserver you could have a stripped down basic database of quotes in the application itself, to extend this connect to the database and download more data.
This method may be best as it lets you use the database data to say populate a website if you wanted to (make a bit of money from ad revenue / promote your app) and also it means if your users dont have an internet connection they can still get some use from your app.
Without more knowledge of the platform I couldnt say what would happen if you try load a 500mb application but I doubt it would be good, though having such a large file locally is a bad idea for a mobile device. I can see this going two ways.
1) Im out and see your application, I set it downloading, pay it no attention and then later check to find it has downloaded 500mb over my mobile phone data package. This could mean a big bill.
2) I start to download your application, it hasnt finished downloading after 10mins, I delete it and dont bother trying again.
You can do something like let the user to enter three character minimum before search from webservice ans user the service result to bind the data.
Check the following links
How to connect to a Webservice from a Windows Mobile Device 6.0
http://msdn.microsoft.com/en-us/library/aa446547.aspx
Let me know if this helps.