Upload files WP7

May 30, 2011 at 10:13 AM

I have tried to upload a file to dropbox with the WP7 lib, but neither storage.Upload(...) nor the long variant with Transfer(stream, ...) has worked.

Both ways I have got an undefined Exception.

I 'm using the last build of the library.

Please help me, I need a solution as fast as possible.

Coordinator
May 30, 2011 at 5:37 PM
Hi,

do you have a sample app which I can debug in my emulator?

Thanks
Dirk

2011/5/30 malefficus <notifications@codeplex.com>

From: malefficus

I have tried to upload a file to dropbox with the WP7 lib, but neither storage.Upload(...) nor the long variant with Transfer(stream, ...) has worked.

Both ways I have got an undefined Exception.

I 'm using the last build of the library.

Please help me, I need a solution as fast as possible.

Read the full discussion online.

To add a post to this discussion, reply to this email (sharpbox@discussions.codeplex.com)

To start a new discussion for this project, email sharpbox@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jul 6, 2011 at 1:49 PM

Has this problem been fixed?

I'm just trying to build a program for WP7 using revision 76533 of the library and get a System.MethodAccessException, when I try to upload a file. The problem is, as far as I can see, that standard System.IO.File methods are used to access the files. On WP7 System.IO.IsolatedStorage should be used instead. Am I missing something important or has this really not been implemented?

Coordinator
Jul 6, 2011 at 8:23 PM
Hi,

can you give me a little bit more context or a code sniplet?

Thanks
Dirk


2011/7/6 DNMobile <notifications@codeplex.com>

From: DNMobile

Has this problem been fixed?

I'm just trying to build a program for WP7 using revision 76533 of the library and get a System.MethodAccessException, when I try to upload a file. The problem is, as far as I can see, that standard System.IO.File methods are used to access the files. On WP7 System.IO.IsolatedStorage should be used instead. Am I missing something important or has this really not been implemented?

Read the full discussion online.

To add a post to this discussion, reply to this email (sharpbox@discussions.codeplex.com)

To start a new discussion for this project, email sharpbox@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jul 7, 2011 at 8:30 AM

Hi Dirk,

based on the sample program for WP7 (DropBoxBrowser.WP7) my program logs in into DropBox. As in this samle, the CloudStorage object is stored in the property CloudAccess and the root folder in the property Root. After successful login I try to upload a file from my isolated storage (the only place where I can store files on my phone) to DropBox using CloudAccess.UploadFile(UploadFile, Root). If I do so, File.Exists(filePath) throws the System.MethodAccessException in the method public ICloudFileSystemEntry UploadFile(String filePath, ICloudDirectoryEntry targetContainer, string targetFileName, FileOperationProgressChanged delProgress). Additional information: Attempt to access the method failed: System.IO.File.Exists(System.String).

Due to the restricted file system on the phone, most methods from System.IO are blocked. For example, instead of System.IO.File.Exists(filePath), isoStore.FileExists(filePath) should be used, where isoStore stands for IsolatedStorageFile.GetUserStoreForApplication().

I'm not sure, if I overlooked something important, since the Simple DropBox Viewer seems to be able to download files from DropBox, even when there is no IsolatedStorage support in Sharpbox. If so, can you please give me a hint where to start from? Otherwise I would change the file access methods to get my project running.

Regards,
Gernot

Jul 13, 2011 at 1:53 PM

Since uploading a file using 

UploadFile(String filePath, ICloudDirectoryEntry targetContainer)

does not work on Windows Phone 7 (see my previous post regarding IsolatedStorage), I tried

UploadFile(Stream uploadDataStream, String targetFileName, ICloudDirectoryEntry targetContainer, FileOperationProgressChanged delProgress)

as an alternative. Unfortunately this doesn't work, either. Now I get a System.NotSupportedException in GetResponseInternal (WebRequestStreamHelper.cs) during the call to request.EndGetResponse(result).

Has anybody got this code running under Windows Phone 7 and successfully uploaded a file to Dropbox?

Jul 18, 2011 at 9:24 AM

Hi Dirk, I have the same problem

When I use

UploadFile(System.IO.Stream uploadDataStream, string targetFileName, AppLimit.CloudComputing.SharpBox.ICloudDirectoryEntry targetContainer)

to do upload

I get System.NotSupportedException

Here is my code snip:

using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
       IsolatedStorageFileStream oneStream = store.OpenFile("test1.txt", FileMode.Open);

       if (oneStream != null)
       {
               m_cloudStorage.UploadFile(oneStream, "test.txt", m_cloudStorage.GetRoot());
               oneStream.Close();
        }

       store.Dispose();
}

and the stack trace is following

   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestStreamHelper.GetResponseInternal(WebRequest request)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestStreamHelper.GetResponse(WebRequest request)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestService.GetWebResponse(WebRequest request)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestService.PerformWebRequest2(WebRequest request, Object context, Stream content, HttpStatusCode& code, WebException& errorInfo)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestService.PerformWebRequest2(WebRequest request, Object context, HttpStatusCode& code, WebException& errorInfo)
   at AppLimit.CloudComputing.SharpBox.StorageProvider.DropBox.Logic.DropBoxStorageProviderService.CommitUploadStream(Object[] arg)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestStream.PerformeDisposeOperations(Stack`1 stack)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestStream.System.IDisposable.Dispose()
   at AppLimit.CloudComputing.SharpBox.StorageProvider.GenericStorageProviderService.UploadResourceContent(IStorageProviderSession session, ICloudFileSystemEntry fileSystemEntry, Stream targetDataStream, FileOperationProgressChanged progressCallback, Object progressContext)
   at AppLimit.CloudComputing.SharpBox.StorageProvider.BaseObjects.BaseFileEntryDataTransfer.Transfer(Stream targetDataStream, nTransferDirection direction, FileOperationProgressChanged progressCallback, Object progressContext)
   at AppLimit.CloudComputing.SharpBox.CloudStorage.UploadFile(Stream uploadDataStream, String targetFileName, ICloudDirectoryEntry targetContainer, FileOperationProgressChanged delProgress)
   at AppLimit.CloudComputing.SharpBox.CloudStorage.UploadFile(Stream uploadDataStream, String targetFileName, ICloudDirectoryEntry targetContainer)
   at SharpBoxTest.MainPage.LoginUploadAsyncCallback(IAsyncResult ar)
   at AppLimit.CloudComputing.SharpBox.CloudStorage.OpenRequestCallback(Object state)
   at System.Threading.ThreadPool.WorkItem.doWork(Object o)
   at System.Threading.Timer.ring()

 

Regards

yuhsien

Coordinator
Jul 22, 2011 at 12:56 PM

Hi,

 

yes I found a bigger issue with the file up and download code on WP7. Currently I'm working on a solution for 1.1.1, sorry :-(

Cheers

Dirk

Jul 26, 2011 at 4:23 AM

Hi Dirk

Thanks for your reply

It will be great solution of dropbox.

Regards

yuhsien

Sep 21, 2011 at 12:21 PM

Hi,

Downloaded and compile 1.1.1 but the upload still errors as previous posts.

Cheers

Redtalon

Coordinator
Sep 21, 2011 at 10:13 PM
What kind of error? Do you have more information? We are working on SR2 which contains a WP7 bugfix, did this help?

Dirk

Sent from my iPad

On 21.09.2011, at 14:21, redtalon <notifications@codeplex.com> wrote:

From: redtalon

Hi,

Downloaded and compile 1.1.1 but the upload still errors as previous posts.

Cheers

Redtalon

Sep 21, 2011 at 10:26 PM

Hi,

@Redtalon:

I am able to download as well as upload files on wp7 to dropbox using the current version 1.1.1. You need to call BeginOpenRequest() before you can upload a file. Have you tried this?

@Dirk:

When uploading a file using the dropbox.UploadFile() method I realized that something inside this method still needs a little more time after the upload has been finished.

For example: I upload a file using the UploadFile method, I specify the parent folder, the filename, a stream, and my fileoperationprogress callback method. The FileOperationProgressChanged event is being fired many times and this way I am able to display a progress bar from 0 - 100%. Until here everything is good :-) But then, for some reason, the UploadFile method is still not finished and let me wait up to 30 seconds, depending on the uploaded file size. The larger the file, the longer I need to wait.

Can someone confirm this?

Sep 22, 2011 at 7:35 AM
Edited Sep 22, 2011 at 7:43 AM

Hi.

Thanks for getting back to me.

Yes it does call BeginOpenRequest.

, ProgressOfFile);

 Tried with multitude of different / combinations, none work.

The app will freeze completely.

 Trying a different bit of code just to write a file in the root: 

ICloudFileSystemEntry file = CloudAccess.CreateFile(Root, filename);

// build the data stream  

Stream data = new MemoryStream ();

 

 

StreamWriter br = new StreamWriter (data);  

br.Write(buff);  

 

data.Position = 0;



 

// upload data

nTransferDirection.nUpload, null, null );  

 

 

 

br.Close();

 

 

 

 

Then I get the error: NotSupportedException on the file.GetDataTransferAccessor

 

Stack trace:

   at System.Net.Browser.ClientHttpWebRequest.PrepareAndSendRequest(String method, Uri requestUri, Stream requestBodyStream, WebHeaderCollection headerCollection, CookieContainer cookieContainer)
   at System.Net.Browser.ClientHttpWebRequest.BeginGetResponseImplementation()
   at System.Net.Browser.ClientHttpWebRequest.InternalBeginGetResponse(AsyncCallback callback, Object state)
   at System.Net.Browser.ClientHttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestStreamHelper.GetResponseInternal(WebRequest request)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestStreamHelper.GetResponse(WebRequest request)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestService.GetWebResponse(WebRequest request)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestService.PerformWebRequest2(WebRequest request, Object context, Stream content, HttpStatusCode& code, WebException& errorInfo)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestService.PerformWebRequest2(WebRequest request, Object context, HttpStatusCode& code, WebException& errorInfo)
   at AppLimit.CloudComputing.SharpBox.StorageProvider.DropBox.Logic.DropBoxStorageProviderService.CommitUploadStream(Object[] arg)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestStream.PerformeDisposeOperations(Stack`1 stack)
   at AppLimit.CloudComputing.SharpBox.Common.Net.Web.WebRequestStream.System.IDisposable.Dispose()
   at AppLimit.CloudComputing.SharpBox.StorageProvider.GenericStorageProviderService.UploadResourceContent(IStorageProviderSession session, ICloudFileSystemEntry fileSystemEntry, Stream targetDataStream, FileOperationProgressChanged progressCallback, Object progressContext)
   at AppLimit.CloudComputing.SharpBox.StorageProvider.BaseObjects.BaseFileEntryDataTransfer.Transfer(Stream targetDataStream, nTransferDirection direction, FileOperationProgressChanged progressCallback, Object progressContext)
   at AudioPhone7.Dropbox.butUploadFile_Click(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

Hope this helps,



Redtalon

 

 

file.GetDataTransferAccessor().Transfer(data,

 

 

CloudAccess.UploadFile(filename, "/MyExample"

Sep 22, 2011 at 7:41 AM
Edited Sep 22, 2011 at 7:44 AM

btw most of the code I am using is from the example provided with the WP7 solution, so the BeginOpenRequest is straight from there.

Sorry for the messed up code, damn editor has a mind of its own!!!

Coordinator
Sep 24, 2011 at 2:41 PM
Hi,

@marcdrexler: Did you enabled the AllowWriteStreamBuffering property? If so the progress shows only the progress for transfering your data into the cache and not over the wire. This is currently an issues with the way HttpWebRequest is handling caching. So the real download will be done in your waiting time :-(

Cheers
Dirk

2011/9/22 marcdrexler <notifications@codeplex.com>

From: marcdrexler

Hi,

@Redtalon:

I am able to download as well as upload files on wp7 to dropbox using the current version 1.1.1. You need to call BeginOpenRequest() before you can upload a file. Have you tried this?

@Dirk:

When uploading a file using the dropbox.UploadFile() method I realized that something inside this method still needs a little more time after the upload has been finished.

For example: I upload a file using the UploadFile method, I specify the parent folder, the filename, a stream, and my fileoperationprogress callback method. The FileOperationProgressChanged event is being fired many times and this way I am able to display a progress bar from 0 - 100%. Until here everything is good :-) But then, for some reason, the UploadFile method is still not finished and let me wait up to 30 seconds, depending on the uploaded file size. The larger the file, the longer I need to wait.

Can someone confirm this?

Read the full discussion online.

To add a post to this discussion, reply to this email (sharpbox@discussions.codeplex.com)

To start a new discussion for this project, email sharpbox@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Coordinator
Sep 24, 2011 at 2:44 PM
Hi,

please try to use our current trunk code base. As I understood in WP7 you have to close the WebRequest before requesting for a WebResponse. We implemented this fix with the following check in http://sharpbox.codeplex.com/SourceControl/changeset/changes/79364 which will be part of SharpBox 1.1 SR2

Cheers
Dirk


2011/9/22 redtalon <notifications@codeplex.com>

From: redtalon

btw most of the code I am using is from the example provided with the WP7 solution, so the BeginOpenRequest is straight from there.

Read the full discussion online.

To add a post to this discussion, reply to this email (sharpbox@discussions.codeplex.com)

To start a new discussion for this project, email sharpbox@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Sep 24, 2011 at 7:08 PM

Hi,

Now get an error on BeginOpenRequest, check code against sample project, identical.

{AppLimit.CloudComputing.SharpBox.Common.AsyncResultEx}

[AppLimit.CloudComputing.SharpBox.Common.AsyncResultEx]: {AppLimit.CloudComputing.SharpBox.Common.AsyncResultEx}

AsyncState: {AppLimit.CloudComputing.SharpBox.CloudStorage.OpenRequest}

AsyncWaitHandle: 'ar.AsyncWaitHandle' threw an exception of type 'System.NotImplementedException'

CompletedSynchronously: 'ar.CompletedSynchronously' threw an exception of type 'System.NotImplementedException'

IsCompleted: 'ar.IsCompleted' threw an exception of type 'System.NotImplementedException'

Cheers

 

Martyn

Sep 29, 2011 at 8:31 AM

Any idea what I am doing wrong here?

Can't even get the example to work with SR2.

Oct 8, 2011 at 4:35 PM
I have the 1.1 SR2 release and I am still hanging during the upload process as it waits, but never receives a response. Downloads are working fine. (I'm still uing WP7.0 libraries, not WP7.5- can upgrade if needed)
 
            //  Convert to Stream for upload
            Stream io = new MemoryStream();
            doc.Save(io);
            io.Position = 0;
 
            try
            {
                ICloudFileSystemEntry fsentry = (App.Current as App).CloudAccess.CreateFile(RequestDir, fileDownload.File);
                ICloudFileDataTransfer fdt = fsentry.GetDataTransferAccessor();
                fdt.Transfer(io, nTransferDirection.nUpload, nullnull);
            }
            catch (SharpBoxException exSB)
            {
                ...
            }
            catch (Exception ex)
            {
                ...
            }
Any help would be great.
Coordinator
Oct 8, 2011 at 5:08 PM
Hi,

sorry for this late response. As I understood there are several problems with the stream in WP7 and currently I'm looking for one who can explain me this. In the meantime I would propose to use the GetResourceURL method and the WebClient of .NET Framework.

What do you think?

Dirk

Sent from my iPad

On 08.10.2011, at 18:35, "RadCam"<notifications@codeplex.com> wrote:

From: RadCam

I have the 1.1 SR2 release and I am still hanging during the upload process as it waits, but never receives a response. Downloads are working fine. (I'm still uing WP7.0 libraries, not WP7.5- can upgrade if needed)
 
            //  Convert to Stream for upload
            Stream io = new MemoryStream();
            doc.Save(io);
            io.Position = 0;
 
            try
            {
                ICloudFileSystemEntry fsentry = (App.Current as App).CloudAccess.CreateFile(RequestDir, fileDownload.File);
                ICloudFileDataTransfer fdt = fsentry.GetDataTransferAccessor();
                fdt.Transfer(io, nTransferDirection.nUpload, null, null);
            }
            catch (SharpBoxException exSB)
            {
                ...
            }
            catch (Exception ex)
            {
...
}
Any help would be great.
Oct 8, 2011 at 9:25 PM

Thank for the response.  I will give it a try.  I don't know enought about the WP7 streaming to help out.  Sorry.