<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How To Tell File Being Uploaded From Progress Block in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/209999#M10454</link>
    <description>&lt;P&gt;Is there any way to know what file is being worked on when the progress block is called?&amp;nbsp; See the working code below - I'd like to be able to put an update on the screen so that the user knows which file is being uploaded.&amp;nbsp; I know that it could be uploading several files synchronously - so this is why I'd like to know which one it is referring to each time the progress block is called.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            [[[dbClient.filesRoutes uploadUrl:remoteFile inputUrl:[NSURL fileURLWithPath:localFile]] setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESUploadError *uploadError, DBRequestError *error)
            {
                if (metadata)
                {
                    NSLog(@"The upload completed successfully.");
                    NSLog(@"File metadata:");
                    NSLog(@"%@", metadata);
                } else if (uploadError)
                {
                    NSLog(@"Something went wrong with the upload:");
                    NSLog(@"%@", uploadError);
                } else if (error)
                {
                    NSLog(@"Something went wrong with the API call:");
                    NSLog(@"%@", error);
                }
                
                ++self.filesUploaded;
                [[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_FILE_UPLOADED object:self];
            }] setProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)
            {
                float percentDone = (float)totalBytesWritten/(float)totalBytesExpectedToWrite*(float)100;
                self.alert.message = $str(@"Uploading File %0.0f%%\n\n",percentDone);
            }];
&lt;/PRE&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:25:05 GMT</pubDate>
    <dc:creator>Eric-H</dc:creator>
    <dc:date>2019-05-29T09:25:05Z</dc:date>
    <item>
      <title>How To Tell File Being Uploaded From Progress Block</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/209999#M10454</link>
      <description>&lt;P&gt;Is there any way to know what file is being worked on when the progress block is called?&amp;nbsp; See the working code below - I'd like to be able to put an update on the screen so that the user knows which file is being uploaded.&amp;nbsp; I know that it could be uploading several files synchronously - so this is why I'd like to know which one it is referring to each time the progress block is called.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            [[[dbClient.filesRoutes uploadUrl:remoteFile inputUrl:[NSURL fileURLWithPath:localFile]] setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESUploadError *uploadError, DBRequestError *error)
            {
                if (metadata)
                {
                    NSLog(@"The upload completed successfully.");
                    NSLog(@"File metadata:");
                    NSLog(@"%@", metadata);
                } else if (uploadError)
                {
                    NSLog(@"Something went wrong with the upload:");
                    NSLog(@"%@", uploadError);
                } else if (error)
                {
                    NSLog(@"Something went wrong with the API call:");
                    NSLog(@"%@", error);
                }
                
                ++self.filesUploaded;
                [[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_FILE_UPLOADED object:self];
            }] setProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)
            {
                float percentDone = (float)totalBytesWritten/(float)totalBytesExpectedToWrite*(float)100;
                self.alert.message = $str(@"Uploading File %0.0f%%\n\n",percentDone);
            }];
&lt;/PRE&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:25:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/209999#M10454</guid>
      <dc:creator>Eric-H</dc:creator>
      <dc:date>2019-05-29T09:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: How To Tell File Being Uploaded From Progress Block</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/210129#M10471</link>
      <description>&lt;P&gt;Hi Eric, yes, you can disambiguate the different progress blocks by setting a&amp;nbsp;variable inside each. You can then factor out the rest of the handling if you want. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;- (void)progressCallback:(NSString*)identifier bytesWritten:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {

    NSLog(@"%@: bytesWritten: %lld, totalBytesWritten: %lld, totalBytesExpectedToWrite: %lld", identifier, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);

}&lt;/PRE&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;PRE&gt;          }] setProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)
         {
             NSString *identifier = @"this is #1"; // or whatever you want
             [self progressCallback:identifier bytesWritten:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];

         }];&lt;/PRE&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;PRE&gt;          }] setProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)
         {
             NSString *identifier = @"this is #2"; // or whatever you want
             [self progressCallback:identifier bytesWritten:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
         }];&lt;/PRE&gt;
&lt;P&gt;Hope this helps!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 21:48:59 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/210129#M10471</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-03-06T21:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: How To Tell File Being Uploaded From Progress Block</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/210175#M10479</link>
      <description>&lt;P&gt;Thanks for the quick reply Greg.&amp;nbsp; But I don't think that's what I'm looking for.&amp;nbsp; Apologies for not being more clear.&amp;nbsp; As you can see below, I'm calling uploadUrl in a loop - for each file that needs to be uploaded.&amp;nbsp; Therefore the setProgressBlock is getting called for each of the files being uploaded synchronously.&amp;nbsp; I'd like to know for which file the progress information is for.&amp;nbsp; Any way to know this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;-(void) uploadLocalChanges
{
    self.uploadLocalChangesCalled = YES;
    DBUserClient *dbClient = [DBClientsManager authorizedClient];
    NSMutableSet* allLocalFiles = [NSMutableSet set];
    [allLocalFiles addObjectsFromArray:self.localFiles.allKeys];
    
    for (NSString* file in allLocalFiles)
    {
        NSDate* localDate = [self.localFiles objectForKey:file];
        NSDate* remoteDate = [self.remoteFiles objectForKey:file];
        NSDate* lastSyncLocalDate = [self.lastSyncLocalFiles objectForKey:file];
        
        if (remoteDate == nil || (lastSyncLocalDate != nil &amp;amp;&amp;amp; localDate &amp;gt; lastSyncLocalDate))
        {
            ++self.filesToUpload;
            //NSLog(@"Uploading file %@",file);
            NSString* remoteFile = [@"/" stringByAppendingString:file];
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString* appPath = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
            NSString* localFile = [appPath stringByAppendingString:file];
            
            [[[dbClient.filesRoutes uploadUrl:remoteFile inputUrl:[NSURL fileURLWithPath:localFile]] setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESUploadError *uploadError, DBRequestError *error)
            {
                if (metadata)
                {
                    /*
                    NSLog(@"The upload completed successfully.");
                    NSLog(@"File metadata:");
                    NSLog(@"%@", metadata);
                    */
                } else if (uploadError)
                {
                    NSLog(@"Something went wrong with the upload:");
                    NSLog(@"%@", uploadError);
                } else if (error)
                {
                    NSLog(@"Something went wrong with the API call:");
                    NSLog(@"%@", error);
                }
                
                ++self.filesUploaded;
                [[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_FILE_UPLOADED object:self];
            }] setProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)
            {
                [self updateFileStatusPercent:@"Uploading ..." totalBytesWriten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
                // Here we can monitor the progress of the transfer:
                //NSLog(@"bytesWritten: %lld, totalBytesWritten: %lld, totalBytesExpectedToWrite: %lld", bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
            }];
        }
    }
    if (self.filesToUpload == 0)
        [[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_FILE_UPLOADED object:self];
}&lt;/PRE&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 02:41:26 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/210175#M10479</guid>
      <dc:creator>Eric-H</dc:creator>
      <dc:date>2017-03-07T02:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: How To Tell File Being Uploaded From Progress Block</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/210342#M10491</link>
      <description>Thanks for following up Eric. I'm not sure if I understand your concern exactly though. It looks like the technique I described should work in your case.&lt;BR /&gt;&lt;BR /&gt;Your updateFileStatusPercent method takes the place of progressCallback in my sample above. You can add an extra parameter to updateFileStatusPercent to identify the specific file, like how I have the identifier parameter in my sample.&lt;BR /&gt;&lt;BR /&gt;For example, your identifier may be your NSString* file. The progress block is defined separately for each file, that is, for each iteration of your loop, so the identifier will be different each time. The subsequent calls to updateFileStatusPercent will then contain the distinct identifiers.</description>
      <pubDate>Tue, 07 Mar 2017 19:08:19 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/210342#M10491</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-03-07T19:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: How To Tell File Being Uploaded From Progress Block</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/210422#M10496</link>
      <description>&lt;P&gt;Apologies - I was being dense.&amp;nbsp; I forgot that I had access to the file variable in the setProgress block.&amp;nbsp; I'm good now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eric&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 03:30:48 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-To-Tell-File-Being-Uploaded-From-Progress-Block/m-p/210422#M10496</guid>
      <dc:creator>Eric-H</dc:creator>
      <dc:date>2017-03-08T03:30:48Z</dc:date>
    </item>
  </channel>
</rss>

