dropbox-sdk-obj-c icon indicating copy to clipboard operation
dropbox-sdk-obj-c copied to clipboard

Upload a file URL from iCloud Drive container leads to file with zero bytes(empty file) no data.

Open IliyanKafedzhiev opened this issue 7 years ago • 12 comments

Upload a file URL from iCloud Drive container leads to file with zero bytes(empty file) no data.

example of fileURL from iCloud Drive containter: file:///private/var/mobile/Library/Mobile%20Documents/M30Q9HQZUK~com~company~AppName/Documents/Monthly%20budget.xlsx

IliyanKafedzhiev avatar Apr 27 '17 09:04 IliyanKafedzhiev

Can you share the code to reproduce this issue? Thanks in advance!

greg-db avatar Apr 27 '17 21:04 greg-db

@IliyanKafedzhiev: Are you still seeing the issue? Do you have code to reproduce?

scobbe avatar May 01 '17 17:05 scobbe

Yes @greg-db I still can reproduce it. Please checkout the following code.

Thank you guys !

DBUploadTask* task = 
[self.client.filesRoutes uploadUrl:@"/aaaassddfRenamedWW/Untitled.pptx"
                              mode:[[[DBFILESWriteMode alloc] initWithOverwrite] autorelease]
                        autorename:[NSNumber numberWithBool:NO]
                    clientModified:fileItem.fileModificationDate
                              mute:[NSNumber numberWithBool:YES]
                          inputUrl:[NSURL fileURLWithPath:@"//private/var/mobile/Library/Mobile%20Documents/M30Q9H9MWK~com~mycompany~MyProduct/Documents/Untitled.pptx"]];
```
    
    [task progress:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)
    {
        [self handleProgressForTotalSize:totalBytesExpectedToWrite currentlyProcessedSize:totalBytesWritten];
    }];
    
    [task response:^(DBFILESFileMetadata* metadata, DBFILESUploadError* uploadError, DBRequestError* requestError)
     {
// here there are no errors but the result file is with zero bytes 
....`

IliyanKafedzhiev avatar May 02 '17 07:05 IliyanKafedzhiev

Guys, I fixed my issue by using this method.


- (DBUploadTask *)uploadData:(NSString *)path
                        mode:(DBFILESWriteMode *)mode
                  autorename:(NSNumber *)autorename
              clientModified:(NSDate *)clientModified
                        mute:(NSNumber *)mute
                   inputData:(NSData *)inputData

IliyanKafedzhiev avatar May 02 '17 10:05 IliyanKafedzhiev

@IliyanKafedzhiev: Great to hear! I've updated the sample documentation to use this method by default (rather than the less explicit upload method). Let us know if you run into any other issues, or have any feedback for the SDK.

scobbe avatar May 02 '17 16:05 scobbe

@IliyanKafedzhiev: Would you mind confirming that you've updated to the latest version of the SDK, then trying your above uploadUrl:mode:autorename:clientModified:mute call with an NSString for inputUrl and not an NSURL?

I think that should make it work. Let me know if you can check this out. Many thanks!

scobbe avatar May 02 '17 18:05 scobbe

This method still does not work with iCloudDrive URL(in this case file path string). It uploads a empty file.

- (DBUploadTask<DBFILESFileMetadata *, DBFILESUploadError *> * _Nonnull)uploadUrl:(NSString * _Nonnull)path mode:(DBFILESWriteMode * _Nullable)mode autorename:(NSNumber * _Nullable)autorename clientModified:(NSDate * _Nullable)clientModified mute:(NSNumber * _Nullable)mute inputUrl:(NSString * _Nonnull)inputUrl;

IliyanKafedzhiev avatar May 03 '17 06:05 IliyanKafedzhiev

@IliyanKafedzhiev Can you share the code you're using to get the file URL? We'll need to make sure we're reproducing that the same way you are to investigate. Thanks in advance!

greg-db avatar May 03 '17 17:05 greg-db

@greg-db I use file coordinator with the following configuration go get access to this file URL.

self.fCoordinator = [[[NSFileCoordinator alloc] initWithFilePresenter:nil] autorelease]; [self.fCoordinator coordinateReadingItemAtURL:fileItem.fileURL options:NSFileCoordinatorReadingWithoutChanges error:&error byAccessor:^(NSURL *newURL) {

IliyanKafedzhiev avatar May 04 '17 09:05 IliyanKafedzhiev

@IliyanKafedzhiev Are you passing newURL (a NSURL) to the inputUrl parameter of the uploadUrl method? That parameter should be a NSString (e.g., newURL.path), and not a NSURL, per Stephen's earlier comment. When I try to do that with the latest SDK, I get an exception.

Also, can you let me know what your fileItem is for reference?

greg-db avatar May 04 '17 22:05 greg-db

Yes @greg-db I did it with newURL.path.

The property fileItem.fileURL of fileItem object returns an NSURL object for file before the reading access via FileCoordinatior.

`@interface MSDirectoryFile : NSObject <NSCoding, NSCopying>

@property (nonatomic, retain) NSURL *fileURL;

@property (nonatomic, retain) NSDate* fileModificationDate;


@end`

IliyanKafedzhiev avatar May 05 '17 08:05 IliyanKafedzhiev

Can you share the code you're using to get that fileURL in the first place? I can't reproduce this with a standard NSURL for a local file, even with the file coordinator.

greg-db avatar May 05 '17 21:05 greg-db