Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createUploadProvider method is missing ! #644

Closed
fiasko131 opened this issue Jun 30, 2017 · 13 comments
Closed

createUploadProvider method is missing ! #644

fiasko131 opened this issue Jun 30, 2017 · 13 comments
Assignees

Comments

@fiasko131
Copy link

fiasko131 commented Jun 30, 2017

Hello,
i use SDK for Android :
My code:

			`       final` String itemPath = "documents/file to copy.txt";
				final Option uploadOptions = new QueryOption("@name.conflictBehavior", "fail");
				final int chunkSize = 640 * 1024; //must be the multiple of 320KiB
				final int maxRetry = 5;

				final IProgressCallback<com.onedrive.sdk.extensions.Item> callback = new IProgressCallback<com.onedrive.sdk.extensions.Item>() {
					@Override
					public void progress(long current, long max) {

					}

					@Override
					public void success(com.onedrive.sdk.extensions.Item item) {
					}

					@Override
					public void failure(ClientException error) {

					}
				};

				CloudActivity.mOneDriveClient
						.getDrive()
						.getRoot()
						.getItemWithPath(itemPath)
						.getCreateSession(sessionDescriptor)
						.buildRequest()
						.post()
can't resolve method------->	.createUploadProvider(mOneDriveClient, input, poidOfFile, com.onedrive.sdk.extensions.Item.class)
						.upload(Collections.singletonList(uploadOptions),
								callback,
								chunkSize,
								maxRetry);`

My dependencies in my build.gradle:

compile ('com.onedrive.sdk:onedrive-sdk-android:1.2+') {
transitive = false
}
compile ('com.google.code.gson:gson:2.3.1')
compile ('com.microsoft.services.msa:msa-auth:0.8.+')
compile ('com.microsoft.aad:adal:1.1.+')

I have the same issue if i try to compile the same dependencies in the new android project.
Any ideas?
Thanks

@daboxu
Copy link

daboxu commented Jul 14, 2017

hi @fiasko131 , the chunked upload is out with release version 1.3.1, try bump your version.

testes with

    compile 'com.onedrive.sdk:onedrive-sdk-android:1.3+'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.microsoft.services.msa:msa-auth:0.8.4'
    compile 'com.microsoft.aad:adal:1.1.+'

and it works for me.

@fiasko131
Copy link
Author

Hi @daboxu , i've updated my dependencies and it works now.
The method works great with local file, but with an inputstream for another cloud provider...it's very slow or fail!?
Is there a method with this sdk to upload from an inputStream from URL?
Or for example, does GoogleDrive provide an inputstream for uploading to Onedrive?

And I take the opportunity to go up an issue I posted on the sdk github for android:
OneDrive/onedrive-sdk-android#124

Thank you for spending time.

Regards

@daboxu
Copy link

daboxu commented Jul 17, 2017

@fiasko131 sorry in the SDK I think we don't support that. The large file uploader is designed for uploading local large files. I looked up the Google Drive's documents and it seems they are the bottle neck of the uploading. I would suggest you download the Google Drive's file to local and then upload it to OneDrive. Thanks for letting me know there is a inputStream interface for Google Drive on Android, we will consider utilize it for future stories.

@fiasko131
Copy link
Author

fiasko131 commented Jul 18, 2017

@daboxu for my application I use sdks for Android of DropBox, Googledrive, and box. With these three sdks I can upload a file directly from a URL and therefore from an InputStream.

  • For googleDrive for example:
    `InputStreamContent mediaContent = null;
    com.google.api.services.drive.model.File body = new com.google.api.services.drive.model.File();
    body.setTitle(name);
    body.setParents(Arrays.asList(new ParentReference().setId(mCurrentDriveFolderId)));
    Drive.Files.Insert insert;
    mediaContent = new InputStreamContent("", new BufferedInputStream(input) {
    @OverRide
    public int read() throws IOException {

      					return 0;
      				}
      				@Override
      				public int read(byte[] buffer,
      								int byteOffset, int byteCount)
      						throws IOException {
    
      					return super.read(buffer, byteOffset, byteCount);
      				}
      			});	
    

mediaContent.setLength(length);
insert = googleDriveService.files().insert(body, mediaContent);
MediaHttpUploader uploader = insert.getMediaHttpUploader();
CustomProgressListener listener = new CustomProgressListener();
uploader.setProgressListener(listener); uploader.setDirectUploadEnabled(false).setChunkSize(MediaHttpUploader.MINIMUM_CHUNK_SIZE);
com.google.api.services.drive.model.File f = insert.execute();`

  • for Box:
    BoxFile f = mFileApi.getUploadRequest(input,checkedName,mCurrentBoxFolderId ).send();

  • for dropBox :
    metadata = dropBoxService.files() .uploadBuilder(currentDropBoxPath+"/"+name) .withMode(WriteMode.OVERWRITE) .uploadAndFinish(input);
    etc ...
    In each case inputstream (input) is from a cloud provider or a URL.
    By this way, I can easily copy a file from one account (same provider or not) to another without going through an outputstream buffer. This is not a good solution for a mobile application.
    I find it curious that the ondrive sdk does not offer this possibility, it's annoying for the user.
    Thank you for your support.

Edit : Sorry for the presentation but I can not understand the function of insertion and tags. :((

@daboxu
Copy link

daboxu commented Jul 18, 2017

@fiasko131 as far as I can read from your example of Box and Dropbox, they both provides the interface as an inputStream as the OneDriveSDK does. The problem is that the inputStream reading bytes from another cloud storage provider is very slow so that's why I proposed you use local storage as a cache. I am wondering have you tested with Box and DropBox with the same input stream? Looking forward for a performance test result.

@fiasko131
Copy link
Author

fiasko131 commented Jul 19, 2017

Hi @daboxu ,
Here is 3 videos showing:
-upload onedrive to box
https://1drv.ms/v/s!Aotc-z6VC9w4gq0M4Vx35566wLPtqA
-upload onedrive to googledrive
https://1drv.ms/v/s!Aotc-z6VC9w4gq0N-ZuOchH6Pe6vkw
-upload box to onedrive
https://1drv.ms/v/s!Aotc-z6VC9w4gq0OWLkuChxAU5qIvQ
As you can see the transfers are very correct except in the case of onedrive with uploadProvider.
In other cases there are no buffer files during the upload.

Performed in 4g (download 7mb / s upload 4mb / s)

Regards.

@daboxu
Copy link

daboxu commented Jul 19, 2017

@fiasko131 thanks for the video, what's your chunksize passed in? That could be a bottleneck I guess.

.createUploadProvider(mOneDriveClient, input, poidOfFile, com.onedrive.sdk.extensions.Item.class)
						.upload(Collections.singletonList(uploadOptions),
								callback,
								chunkSize,
								maxRetry);

@fiasko131
Copy link
Author

@daboxu i try 320,640,1280 but no way....??

@daboxu
Copy link

daboxu commented Jul 19, 2017

320 Bytes? The server side supports max 60 * 1024 * 1024 which is 60 MiB.

@fiasko131
Copy link
Author

fiasko131 commented Jul 19, 2017

Sorry 320x1024, 640x1024, 1280x1024

@daboxu
Copy link

daboxu commented Jul 19, 2017

thanks for clarifying that, I will take a look to see how to uplaod from another cloud provider. Another approach you can try is the upload from uri API which is under preview, https://dev.onedrive.com/items/upload_url.htm. Unfortunately we don't have a plan to integrate it into SDK yet, so you need write the HttpRequest part by your self, while you can get the access token from the oneDrive client.

@fiasko131
Copy link
Author

ok @daboxu ,
Thank you very much for your efforts. This is not a criticism of your work but I think the ability to work with a URL or inputstream is essential for cloud sdk like onedrive. Just as the ability to manage multiple sessions and pass files from one account to another by building persistent client objects as on other sdks clouds. This is just my opinion.

@patrick-rodgers
Copy link
Contributor

As part of a repository clean up effort we are closing older issues. If this issue remains, please: open a new issue, reference this issue, and provide any additional details that may help in resolution. Thank you for your understanding as we work to improve our responsiveness.

@OneDrive OneDrive locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants