Post

1 follower Follow
0
Avatar

Uploaded files are broken

Hi

I'm uploading files with

$action = $api->file->upload($filePath,$filename);

I get a valid podio Id in the end.

However some files are broken. The local source is OK, but the uploaded file is broken. This happens randomly.

An example would be a rar file with podio id 21078436. I shows as rar but when I download it from podio and try to extract it gives me error in file. Same happened to several .xls files, and several .jpegs - jpegs looked like half uploaded.. These files are less in KB than the source files - like these were not completely uploaded. But how can I get a valid podio id if something happened with the file during upload?

Please advise

Thanks

Kalin

Kalin Sivov

Please sign in to leave a comment.

8 comments

0
Avatar

Sure. That's the first version which now has try/catch but the problem appeared with this version - some files were uploaded ok, some not. (I haven't run the try/catch version yet - need to be sure that files will be uploaded ok because there are lots of them and I won't be able to check all manually later.)

 

$jira_attachments = getAllFromTable('jira_attachments');

$jira_issues = getAllFromTable('jira_issues');

for ( $mm = 0 ; $mm < count($jira_attachments) ; $mm++ ){

    $filename = trim(stripslashes($jira_attachments[$mm]['jira_filename']));

    $jira_file_id = trim(stripslashes($jira_attachments[$mm]['jira_id']));

    $jira_id = $jira_attachments[$mm]['jira_issue'];

    $jira_key = '';

    for ( $yy = 0 ; $yy < count($jira_issues) ; $yy++ ){

        if ( $jira_issues[$yy]['jira_id'] == $jira_id ){

            $jira_key = $jira_issues[$yy]['jira_key'];

            break;

        }

    }

    if ( $jira_key != '' ){

        $filePath = $BASEPATH.'project-attachments/'.$jira_key.'/'.$jira_file_id;

        if ( is_file($filePath) ){

            $action = $api->file->upload($filePath,$filename);

            update_table('jira_attachments','id', $jira_attachments[$mm]['id'],'podio_id',$action['file_id']);

        }

    }

}

Kalin Sivov 0 votes
0
Avatar

Can you check if the file works from podio.com? I have never heard of any files being corrupted on our end if it was uploaded correctly. My guess would be that there is either a problem with the upload or the download on the client side, not the server side.

Christian Holm 0 votes
0
Avatar

Yes, they can be uploaded to podio.com through your web interface. This happened when I uploaded several (38) files one after another through the API. When I download the broken files they are broken. Like images are not full, like they are missing their final data. XLS files do not open at all. And the files I've uploaded through API and then downloaded them back from podio.com (the broken ones) - these have smaller sizes than the source ones on my PC. Obviously they haven't been completely uploaded but I'm wondering: podio returns me an ID so I assume file is uploaded OK. Is there a way to check if the file is the same - like a hash or something that I can calculate from my local file and compare to a hash you provide for the file that's already on podio server?

Kalin Sivov 0 votes
0
Avatar

Can they be downloaded from the web interface? I am pretty sure the problem is with the download in the client, and can almost guarantee that this is not a problem with the API. It will not return a file_id until the upload is complete, but completion is something that is set by the uploader.

Christian Holm 0 votes
0
Avatar

Yes, they can be downloaded, but appear broken.Even the thumbnails created for the broken images on the site don't look right - they appear cut with a gray background for the missing portions of the images, and the fullview shows the same cut images. Unfortunately, I changed them manually and don't have a sample to attach but I hope you understand me.

What do you mean by "completion is set by uploader"? The uploader is a PHP script, is there a check or a param I'm missing in the API call:

$action = $api->file->upload($filePath,$filename);

Kalin Sivov 0 votes