web api mvc knockout file upload with entity model - asp.net-mvc

I have a web api 2 which return an entity set. In the entity set I have a property for an image url. When posting the model back using knockout I want to be able to upload a file. I have seen posts where the upload is done outside of the main post. However as the entity is database first I need to know how the post can send back the knockout view model data but also pass over the uploaded file which will then be saved to a local folder and the image url stored in the model.
Many thanks

Related

Rails uploads for new object

When creating a new record (rails default new action), the object id is nil b/c it's unpersisted in the db.
When uploading objects, they're usually tied to an id (using paperclip).
When my user clicks on new, and I want to provide a dropzone.js area for ajax upload, how do I tie that image/file to the post object when it has no id?
If they discard or exit the browser, I would have orphaned temp images/files...
I'm having trouble connecting the dots between an object upload for a new record.
Can someone help me work out the controller logic for this? I can do it pretty easily in a separate action after the object is created, but not before.
I made a Gem to solve this kind of problem.
It works on top of paperclip and is not intrusive. To enable the functionality, you need to replace paperclip's has_attached_file with has_attached_upload.
Using Rails Pallet gem...
First, you need to upload the file to your server performing POST /uploads with file attribute. The response will give you an identifier related to that file.
Then, sending the identifier, you can update your own record. The gem will copy the file to your record after that.
This way, you can upload files before persisting your record.
You can see a full example on gem's README

Save to OneDrive from ERP

We want to save documents to individual OneDrive Folders.
Currently:
User "Tim" generates a customer overview (Last visits, Revenue etc.) in our ERP-Sytem from Customer "TomCompany" and it will be automatically saved in an FTP-Folder. He's now able to have a look on this file at customers site with Good Reader on his iPad.
Plan:
First step: The customer overview should be saved directly to OneDrive, instead of an FTP-Folder.
Second step: Every Sales Person has his own OneDrive account, so it should be saved to his own account with user-Parameters etc. (which is not a Problem to manage in our ERP-API).
The question is: Is it possible to connect to OneDrive from a different System like ERP. "SaveFileToOneDrive with Authentication"
You can 'connect' to OneDrive through the given API with JavaScript.
Here is an example: https://dev.onedrive.com/sdk/js-v7/js-picker-save.htm .
You can now add the 'Save to OneDrive' button on every page you need it.
If not noticed yet, some examples for the API: https://dev.onedrive.com/sample-code.htm
Hope this helps you to solve your (for me still unknown) problem ;-)
I implemented own windows live API because of I found some problems with standard live api. It is based on REST API so there is layer with objects (file, folder, etc...) and each object has some equipment (i.e. file has method for upload and download file). Second layer is for communication with server side and object layer send requests into second layer which send it into server. Server sends response and second layer return this response into object layer.
I implemented onedrive function mainly because of I developed application which uploads some files into onedrive.
So it is very simple to use it. I describe it on webpage https://wlivefw.codeplex.com/
You can sign as user which onedrive want to use by connection object. Then you will need folder id where you want to create new file. Then you create file object with parent_id set to folder id, name (is required) and description (optional). And now you call File.Create(file object which you created, Stream object - data of origin file, OverWriteOption - if you want to overwrite file if exists or not or create with new name, and progress handler - delegate to method which you want to invoke when progress changed).
File uploading is implemented by BITS protocol, so you can upload file greater than 60MB. File is uploaded by fragment so if fragment uploading fails you can very easy send this fragment again - in exception when uploading fails is delegate to continue method which continue upload from last successfull fragment.
I would like to improve this library so library is free to use as well as source code. Please if you will expand this library send me your changes and I will build new version, etc... Thank you and I hope it is usefull.

Adding an attribute to an entity on fetch from a Doctrine-connected Resource

I'm using Apigility on ZF2 and I have a Doctrine-connected service and I want to send a custom field that doesn't exist in the table the service is connected to.
For example, I'm uploading an image to the API, and storing the necessary data to the table and uploading the image to a CDN. I would then want to return the CDN-generated URL to the consumer along with the entity. Unfortunately, I am not able to store the URL in the table as the URL is generated per request.
What would be the best way to solve this?

Orbeon Form Builder to send all files on save

We implemented a web service that gets called on save. Can we get Form Builder to send all files uploaded in the form every time the form is saved, instead of just the files that were newly uploaded since the last time the form was saved?
I imagine you're implementing the persistence API. Assuming this is the case, the short answer is no.
But then, why would you want that to happen? If a file has already been saved to your persistence layer, when the data is saved you get the form definition with a "link" to that saved file. If you need to retrieve it, you can do so, but, unless I misunderstand what you're doing, you don't need to get it back from Form Builder.

Trying to access the ASPNETDB.MDF database file to get user information.. ASP.NET MVC

Hey everyone... I'm trying to access user information that's contained within the ASPNETDB.MDF file. I'm using ASP.NET MVC. This file gets created when you launch the ASP.NET Configuration tool from Visual Studio. So, I create users, roles, etc. via this ASP.NET Configuration tool, and the data gets saved to this database file.
I'm needing to gain access to user information (just the user name) to use within my application. For example, what I'm trying to do is populate a drop down list with a list of user names (which were created from the ASP.NET Configuration tool, and therefore reside within this ASPNETDB database file). I think if I can figure out how to get that information then I can figure out the rest.
Is there any other way someone would suggest me going about this? I could create a separate users table in my main database, but I would rather use the one in the ASPNETDB database that's already created, just so I use one source for my user's information and not two.
You can use Membership.GetUser() method to get all users in the database as a MembershipUser.
You can also use following LINQ Query to get a list of user names
var users = from user in Membership.GetUsers()
orderby user.UserName
select user.UserName

Resources