how can we upload images Using SignalR in asp.net MVC
i am new on it Please help me out this how we can upload and download images from SignalR chat app.
Thanks
There is no out-of-the-box method for this.
You can do that, but little more efforts are required. To achieve that you would be needing below steps:
1) First you need a server where you upload a file. For this make upload file service to send byte data (Uploading byte data tutorials can be found over google).
2) Once you upload file via web service, on success it should return the path of the server and file name (where that was saved on server).
3) After getting the path send this path as simple message (As you are already sending simple text message with Signal R). And add additional property to differentiate between normal text message of media message.
4) On receiving side (second user whom you are chatting with) check if the message has that additional property (which you added in previous step). If additional property is found, use that URL or file path to download the image from server and save it locally.
Related
I've built a feature to allow users to upload files from a mobile app. I have a RESTful .NET C# Web API endpoint which stores the files BYTE_ARRAY in a SQL Server table. No problem.
Now, when the user wants to view the file, my question is, what options to I have to send them the file?
The user will be on some page which shows some content. If they click this link, I will call some endpoint and I will get the record they are interested in from the table with the files. Now, keep in mind that they can upload any type of file (Word, PDF, Excel, etc.). When I initially store the BYTE_ARRAY I also capture its content type so it can be reconstructed.
Now, my question is
Do I reconstruct the file on the server (if so how) into its type (a PNG will reconstruct to a PNG based on its content type; a Word doc, into a Word doc based on its content-type, etc.). Then, I persist the file in some temp storage location. Then I send back to the app (UX) the new URL for the asset. Then the app (UX) will call back to that endpoint and get the file and do whatever it wants (i.e., https://my-website.com/somePath/fileName.fileExtension)
Do I respond to the app (UX) with the Stream somehow and also provide the content type, which accomplishes the above - in that a file is being sent over HTTP which the app (UX) can do something with?
I went with Google's Firebase! Problem solved!
I am building an app using ASP.NET C# MVC5. You can add records to a database and these records can have images attached to them (it can be a single image for now if it makes it more complex).
I have seen some other posts on storage uploads but I don't see them working for me:
Upload File to Amazon S3
Upload files directly to Amazon S3 from ASP.NET application
How to upload a file to amazon S3 without passing it by a server?
Idea:
Upload a file (image) to Amazon S3 without the data passing through my server.
Persist any data on the form that was entered by the user (I'm happy with a post-back, modal or no-refreshing of the page)
Save a database value in a File table with the name and type of the file etc. that was uploaded (this will also be linked to the item that they are associated with)
Process:
User selects file to upload and presses upload button
File is uploaded directly to amazon (c# async method?, ajax?)
Thumbnail version is also created and uploaded to amazon using the same method? ('-thumb' is appended to filename)
Database records created with filename, amazon fileKey, fileType etc. for both files
(optional) thumbnail is then shown on-screen next to the uploader
User presses 'Save' to save the record along with the image information
When the user goes to save the item information (could be creating a new record or editing an existing one), the file information can be attached (if it isn't attached at the point of uploading the file??)
Constraints:
Avoid using client-based solution for improved app performance and accessibility across platforms (so avoid JavaScript, and definitely flash)
Minimise possibility of the user uploading a file and forgetting to save (or the browser crashing and loosing the link to the file that has been uploaded)
If I knew more about ASP.NET MVC I would have liked to have more suggestions or ideas. I wonder about using async methods or ajax calls to stop the page re-loading and loosing inputted data.
I have downloaded the Amazon SDK and built some classes around it but realised that it wasn't that useful if I'm not uploading via my app!
I took samples for client side upload from https://github.com/floatingfrisbee/amazonfileupload which was fairly useful (I managed to get it working in my app for client side uploads) but there is a lot missing from that solution to fit my problem and I would like a neat, reliable solution for my more complex problem.
Any ideas very welcome!! I'm really struggling to come up with something.
UPDATE 15.12.2016
To clarify, I would like to minimise the amount of client-side processing to the point that a low powered mobile device wouldn't struggle to process the request (obviously if the device can't handle simple image uploads then I don't need to worry).
In terms of server-side processing, the main thing I want to avoid is uploading the image via the server for bandwidth reasons, any other processing I am very happy to happen on the server.
I just wanted to ask is it possible to upload files to IIS server? If it's possible please describe me how to do it, thanks. I've been using google since 1h and i found nothing.
If all you need is file upload to your web server, you could set up FTP on your server
http://www.iis.net/learn/install/installing-publishing-technologies/installing-and-configuring-ftp-7-on-iis-7
If you are looking for a file upload capability for your web application, you can use the FileUpload control. The file would be POSTed to your page once you submit your form. The MSDN page has a an example of how to use the control and save the file on the server side.
Create a web application that has file upload capability
Host the web application in IIS.
Files uploaded will be dropped in your applications folder.
Take a look at for an example of file upload with WebApi: http://blogs.msdn.com/b/henrikn/archive/2012/03/01/file-upload-and-asp-net-web-api.aspx
I need to find a way to upload asynchronously multiple files.
I want to make a smtp client, User can chose files, create message and then send the mail.
I use ajaxfileupload but it create a folder witch look like c:/windows/tem/_ajaxFileUpload/[a guid]/[uploaded files]
is it possible to determine the guid and then find files to attach without saving it to an other folder.
this must be done after user click on send button.
One possible option is the HTML 5 File Api which allows client side uploads. Here is a tutorial on it http://www.html5rocks.com/en/tutorials/file/dndfiles/
I have used it in conjunction with a MVC 4 C# application, and have successfully got it to post (ajax post) file contents to an API Controller which can then be used to persist the file. While you don't mention if you are using MVC, the same should be possible using any sort of service.
Hope this helps.
I am developing a web application in C#.net. I need to edit a file placed on the server in browser it self(Without downloading it on local machine) and when I save that file, the changes should be reflected in file. For this I want to use google API but I don't know how can I use this.
I want to do like below.
When I click on file name, it should open in browser.
When clicked on edit, it open in edit mode in browser using google doc.
When I save that file, the changes should be reflected in my file which is placed on company server.
How can I do all this thing with google doc API?
Install Google Drive on your server.
Edit the file in Google docs, let Google Drive sync it to the local hard drive.
It is not possible for HTTP protocol, because the basics system doesn;t support it. You can open the file but the file will be downloaded to your local machine in then it will open, you have to specify the MIME type in IIS.
You can use two ways to do a similar job done.
1 By Using FTP
2 Customized solution : Make a page put a text field and load the file (.cs) in it and with submit save it to the file back.
You can embed a google doc in Webpages. But the file would be accessed and saved on Google's servers and not your company server:
Wordpress allows you to do it. Potentially you can see if it possible to do it in a similar way:
http://en.support.wordpress.com/google-docs/
I am not sure if Google has an option of accessing docs from servers outside google's domain.