Is it possible to return custom data from a file upload?

We are using the JavaScript FileManager control to connect to SharePoint using the Microsoft Graph API.  When a file Upload successfully completes we need the url and id of the file that is now uploaded to SharePoint.  However in the args of the 'success' event they dont exist.  Is it possible to return this data (plus anything else we may need) from the Upload?  i.e. Would it be possible to return the uploadResponse object from the code sample below?

API



Javascript




4 Replies 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team November 26, 2020 02:23 PM UTC

Hi James Cullis,  
 
Greetings from Syncfusion support. 
 
Currently, we are checking your requirement with FileManager component. We will update the details within two business days on 30th November 2020. 
 
We appreciate your patience. 
 
Regards,  
Sowmiya.P 



SP Sowmiya Padmanaban Syncfusion Team November 30, 2020 01:08 PM UTC

Hi James Cullis,  
 
Thanks for your patience. 
 
You can send the additional data in response header for upload operations and also add the header key value in startup.cs file. 
 
Please, refer the below code snippet. 
 
[Route("Upload")] 
        public IActionResult Upload(string path, IList<IFormFile> uploadFiles, string action) 
        { 
            FileManagerResponse uploadResponse; 
             uploadResponse = operation.Upload(path, uploadFiles, action, null);   
            if (uploadResponse.Error != null) 
            { 
               Response.Clear(); 
               Response.ContentType = "application/json; charset=utf-8"; 
               Response.StatusCode = Convert.ToInt32(uploadResponse.Error.Code); 
               Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = uploadResponse.Error.Message; 
            } 
            Response.Headers.Add("bloburl", "www.google.com"); 
            return Content(""); 
        } 
 
Startup.cs 
 
  public void ConfigureServices(IServiceCollection services) 
        { 
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 
            services.AddCors(options => 
            { 
                options.AddPolicy("AllowAllOrigins", builder => 
                { 
                    builder.AllowAnyOrigin() 
                    .AllowAnyMethod() 
                    .AllowAnyHeader() 
                    .AllowCredentials() 
                    .WithExposedHeaders("bloburl"); 
                }); 
            }); 
        } 
 
 success: function(args) { 
    if (args.action == "Upload") { 
      console.log((args.result as any).e.target.getResponseHeader("bloburl")); 
    } 
  } 
 
Please, refer the sample and service link: 
 
 
 
Note: Run the service and refer the local host URL in FileManager sample. 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 


Marked as answer

JC James Cullis November 30, 2020 01:40 PM UTC

Thanks for your reply.  This is exactly what we were looking for.


SP Sowmiya Padmanaban Syncfusion Team December 1, 2020 04:22 AM UTC

Hi James,  
  
We are happy to hear that your problem has been resolved. Please contact us, if you need any help from us. 
  
Regards,  
Sowmiya.P 


Loader.
Up arrow icon