dropbox-sdk-obj-c
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.
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
Can you share the code to reproduce this issue? Thanks in advance!
@IliyanKafedzhiev: Are you still seeing the issue? Do you have code to reproduce?
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
....`
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: 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.
@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!
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 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 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 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?
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`
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.