Class FileController
The File Controller is a controller that allows the upload of files to the Ayuda Platform.
Namespace: Ayuda.BMS.Splash.Areas.Pi.Controllers
Remarks
This web service can be accessed using an address similar to the following: https://[AYUDA DEPLOYMENT URL]/Juice/Pi/File
Methods
Download(Guid)
Downloads a previously uploaded file.
Declaration
public ActionResult Download(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id |
Returns
Type | Description |
---|---|
System.Web.Mvc.ActionResult | The binary data of the file. |
Remarks
Notes
- If the file does not exist, the "404 Not found" code will be sent rather than the usual Json error response.
- If a internal problem occurs, the "500 Internal server error" will code will be sent.
- The mime type of the file is always "application/octet-stream".
Store(Guid, Int32, String, Guid)
Assembles the uploaded blocks for a file and moves it into
the database.
The FileStoreModel can be used as template to fill in the fields.
Declaration
public JsonResult Store(Guid id, int blockCount, string name, Guid fileExtension)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | The id of the file. This is the same id used while uploading the blocks. |
System.Int32 | blockCount | The number of blocks that were sent. |
System.String | name | The name of the file. |
System.Guid | fileExtension | The type of file uploaded. Values for this field can be found in FileExtension. |
Returns
Type | Description |
---|---|
System.Web.Mvc.JsonResult | A boolean result encoded in Json. true if the operation succeeded, false in case of failure. |
Upload(Guid, Nullable<Int32>, HttpPostedFileBase)
Upload a file.
The file can be uploaded in parts or "blocks" that are numbered sequentially
(starting with 0) according to the location of the data in the file. Each request
can accept up to 4MB of data. Blocks can be uploaded in any order or
even simultaneously. Each block may also be of different sizes.
If the file is completly sent in one call, you can use block index 0 or
simply omit the
If the upload of a block fails, it is possible to re-attempt the upload
using the same block index.
Once all the blocks have been successfully sent, use the Store(Guid, Int32, String, Guid)
method in order to move the completed file into storage, even if the file
was sent in one block.
Declaration
public JsonResult Upload(Guid id, int? blockIndex, HttpPostedFileBase data)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | A unique identifier for the uploaded file. All blocks must use the same id. |
System.Nullable<System.Int32> | blockIndex | The index of the block of data being sent. This field can be omitted if the file is sent with a single call. |
System.Web.HttpPostedFileBase | data | The data for the block, sent as if sending a file for the "Data" field.(MaxDataSize:4MB) |
Returns
Type | Description |
---|---|
System.Web.Mvc.JsonResult | A boolean result encoded in Json. true if the upload succeeded, false in case of failure. |