Uploaded files are broken

Comments

8 comments

  • Kalin Sivov

    Any updates?

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Can you share your entire script?

    0
    Comment actions Permalink
  • Kalin Sivov

    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']);

            }

        }

    }

    0
    Comment actions Permalink
  • Kalin Sivov

    Any news on that?

    0
    Comment actions Permalink
  • Christian Holm

    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.

    0
    Comment actions Permalink
  • Kalin Sivov

    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?

    0
    Comment actions Permalink
  • Christian Holm

    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.

    0
    Comment actions Permalink
  • Kalin Sivov

    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);

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk