I'm currently accessing a 3rd party restAPI using ServiceStacks IRestGateway with my own backing class. It's basically the same as the ServiceStack.Stripe gateway.
My issue is that I'm not sure how to handle File uploads. I know using one of the service clients you can easily do file uploads. Is there a way to re-use this existing implementation without switching to a service client?
The IRestGateway does not include any APIs for HTTP File Uploads. If you need to a send a file with those restricted APIs you'd need a DTO to include a byte[] property to capture the File contents as well as basic metadata like the file name, file/content type, etc.
An alternative to uploading files with ServiceStack's C#/.NET Service Clients is to use the HTTP Util extension methods which provides simple APIs to upload files via FileInfo for Stream.
Related
I'm interested in adding a security front end to AzureStorage for authentication, access control, excessive usage (rate limiter), and other features.
I've read repos on Github regarding ASP.NET Core (I'm at 5.0), however during this research I came across many issues regarding HTTP CHUNKED, and do want broad browser support (Desktop and mobile) to simply GET the ASP.NET Core protected front end, and then use that CHUNKED verb to resume downloading from Azure Storage.
How can I use ASP.NET Core to support this feature in supported Web Browsers using Blob or other implementations of Azure Disk?
I'll provide links to docs and example you can use as a reference. If I understand correctly, you want to look at the BlockBlobClient class if you're wanting to upload data in chunks.
Here's a link to the API reference for HTTP level requests. Specifically it's the Put Block request, which is what gets called when doing one of these chunked uploads through the client. You mentioned HTTP CHUNKED, I assume you're referring to the Transfer Encoding : Chunked header and the transfer mechanism? It looks like HTTP/1.1 is the supported version for the Azure Blob Storage API.
I'm not entirely clear on your concerns but I know chunked transfers are not supported in HTTP/2. Not sure what you would do about that until the service is updated at some point in the future. You said you were building a front-end, which I assume is likely a JavaScript based application of some sort? If so, you can use the Blob Storage JavaScript client library. Obviously if you're uploading from inside ASP.NET, then use the C# package.
HTTP API Reference : https://learn.microsoft.com/en-us/rest/api/storageservices/put-block
Example : Upload video in chunks Azure blob storage
Docs : https://learn.microsoft.com/en-us/dotnet/api/azure.storage.blobs.specialized.blockblobclient?view=azure-dotnet
I have a need to create a pdf or html document within a Node.js express API which then sends that document over HTTP to an API managing our CMS.
So functionally I would like to create the document and POST it as part of a multipart-form upload POST request to an external service.
I see how to do this if after I create the file, I then turn around and write it disk. After that point I can do a read stream of the file from that path to format the POST request with the file.
However I'm wondering how I can perform this action without writing the file to disk and then reading it into a read stream. It seems I should be able to accomplish this without that IO.
Anybody able to point me to a good example or library that does something along these lines?
You can extend Writable and/or Readable streams. By the first look this library do what you need, with the same way - extending built-in streams.
I have a HTML5 static site and use Parse as the back end through REST API.
So my application id and REST API key are completely open to the public.
My classes have ACL so it should be relatively OK. But I also upload files to https://api.parse.com/1/files/ using JavaScript through REST-API .
How can I allow that only logged in users can upload files? Unlike normal classes on which I can set class wide ACL, anyone can upload files to my parsing application.
First off I would ask why you are using the REST API instead of the native JavaScript API... the JavaScript API uses the REST API under the covers, it just adds a nicer layer of interaction to work with.
Anyway, that aside you can't stop people from uploading files unfortunately. You can stop them from assigning those files to records via ACLs though, and you can do a cleanup on files that are not linked to objects.
I'm writing a node SDK and one of the endpoints allows for a file_upload parameter. I'm currently using the standard https library to make my calls, and I wonder if I should continue using it or move to something the "requests" library given that I need to do file uploads.
Here is an article I was reading through to build multi-part file upload functionality into the https module, but the article doesn't say the best way to combine the multi-part file form data and additional parameters say "test_mode=true" or something like that.
how to upload a file from node.js
Wondering if I should move over to requests complete or if this approach seems good then how can I add the above multi-part form functionality but extend it to allow for additional parameters in the body as well as a file binary.
The request module uses the form-data module for sending multipart/form-data requests. You could also use form-data by itself if you don't want to use request.
Is it possible to create a document inside document library using just client-side javascript?
Just a simple text or xml file...
There are examples on how to create/delete a folder or delete a file, or update a document property. And you can do anything you want with list items.
But what if I need to create a document in a document or forms library with ECMAScript object model in SP2010, or calling web services via ajax in MOSS? Is it feasible?
Of course you can do it. You just need to have content of file as a Stream or byte[].
Use such code to create file in library.
ok, i found there are multiple ways to do it, though all of them are normally used in desktop apps, not in browser.
Here is the list:
RPC: Simple ajax POSTing to _vti_bin/_vti_aut/author.dll can do the job quickly if you don't need to set metadata or handle multiple content types
Copy Web Service: CopyIntoItems method of copy.asmx service accepts base64-encoded file body
HTTP PUT: You can simply PUT your file to the desired destination, though this method can by unsupported by some browsers