We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Upload file to dropbox not working ....

Thread ID:

Created:

Updated:

Platform:

Replies:

130343 May 8,2017 07:58 AM May 10,2017 07:05 AM Xamarin.Forms 6
loading
Tags: XlsIO
StephenH
Asked On May 8, 2017 07:58 AM

I am using Xamarin Studio to develop a proof of concept app with Xamarin Forms based on the Dropbox API  example here ...
https://blogs.dropbox.com/developers/2015/06/introducing-a-preview-of-the-new-dropbox-net-sdk-for-api-v2/

I populate my workbox then save it based on your examples..

                                                          foreach (var item in tmpResult)
                        {
                            rowcount++;
                            worksheetUp.Range["A" + rowcount].Text = item.InspectionItemDescription;
                            worksheetUp.Range["B" + rowcount].Text = item.Category;
                            worksheetUp.Range["C" + rowcount].Text = "Test comment " + item.OID;
                            worksheetUp.Range["D" + rowcount].Text = "Pass";
                        }
                        MemoryStream memstream = new MemoryStream();
                        workbookUp.SaveAs(memstream);
  

Then I try to upload it ....

                                                          var updated = await dbx.Files.UploadAsync("/SPHTEST.xls",
                                WriteMode.Overwrite.Instance,
                                body: memstream);
  

but it gives a general error about reaching the host...I know this is false because it downloads a file 5 lines before it generates this file to be uploaded.

Do I need to write it to storage first ?

Thanks in advance for ANY help you can offer.....

StephenH
Replied On May 8, 2017 12:57 PM

OK, so I changed the iOS "HTTPClient implementation" from managed to NSURLSession and it upload and created the file but it's empty.

can someone .. anyone verify this code is correct and should contain the workbook?

IWorkbook workbookUp = application.Workbooks.Create(1);
                        IWorksheet worksheetUp = workbook.Worksheets[0];
                        int rowcount = 0;
                        foreach (var item in tmpResult)
                        {
                            rowcount++;
                            worksheetUp.Range["A" + rowcount].Text = item.InspectionItemDescription;
                            worksheetUp.Range["B" + rowcount].Text = item.Category;
                            worksheetUp.Range["C" + rowcount].Text = "Test comment " + item.OID;
                            worksheetUp.Range["D" + rowcount].Text = "Pass";
                        }
                        MemoryStream memstream = new MemoryStream();
                        workbookUp.SaveAs(memstream);
 

 

Mathu Mohan Vijayakumar [Syncfusion]
Replied On May 9, 2017 09:29 AM

Hi Stephen, 
 
We suspect that the issue might be occurs due to the stream position is not set after saving the workbook. So, we request you to set the stream position to zero before upload as shown below. 
 
Code Example: 
          
//Saving the workbook as stream 
workbook.SaveAs(stream); 
//Positioning the stream 
stream.Position = 0; 
//Closing the workbook 
workbook.Close(); 
 

Also, we have prepared a sample with the above mentioned changes and the sample can be downloaded from the below link. 
Sample Link: 
 
Kindly try this sample and let us know whether the issue is resolved at your end. 
 
Regards, 
Mathu Mohan V A 


StephenH
Replied On May 9, 2017 09:57 AM

OK, that put a file up there but no data :(This code should work right ?The values are in the worksheet when I debug print them ...     IWorkbook workbookUp = application.Workbooks.Create(1);                         IWorksheet worksheetUp = workbook.Worksheets[0];                         int rowcount = 0;                         foreach (var item in tmpResult)                         {                             rowcount++;                             worksheetUp.Range["A" + rowcount].Text = item.InspectionItemDescription;                             worksheetUp.Range["B" + rowcount].Text = item.Category;                             worksheetUp.Range["C" + rowcount].Text = "Test comment " + item.OID;                             worksheetUp.Range["D" + rowcount].Text = "Pass";                             //Display the values                              Debug.WriteLine(worksheetUp["A" + rowcount].Text);                             Debug.WriteLine(worksheetUp["B" + rowcount].Text);                             Debug.WriteLine(worksheetUp["C" + rowcount].Text);                             Debug.WriteLine(worksheetUp["D" + rowcount].Text);                         }                         MemoryStream memstream = new MemoryStream();                         workbookUp.SaveAs(memstream);                         memstream.Position = 0;                         workbookUp.Close();  

StephenH
Replied On May 9, 2017 09:59 AM

I have pasted the code formatted but it does not keep the formatting when I save it for some reason, am I missing something?



StephenH
Replied On May 9, 2017 11:44 AM

OK, I did some troubleshooting and autocomplete and referenced a similar variable above the one I wanted :(

The additional code segments you provided fixed my issue THANK YOU!


Abirami Varadharajan [Syncfusion]
Replied On May 10, 2017 07:05 AM

Hi Stephen,  
 
Thank you for updating us. 
 
We are glad that the issue is resolved at your end. Please let us know if you need any further assistance. 
 
Regards, 
Abirami. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;