protected function createParts($api_key, $metadata, $upload_data)
    {
        $parts = [];
        $max_part_size = FilestackConfig::UPLOAD_PART_SIZE;
        $max_chunk_size = FilestackConfig::UPLOAD_CHUNK_SIZE;

        $num_parts = ceil($metadata['filesize'] / $max_part_size);
        $seek_point = 0;

        // create each part of file
        for ($i=0; $i<$num_parts; $i++) {

            // create chunks of file
            $chunk_offset = 0;
            $chunks = [];

            if ($this->intelligent) {

                // split part into chunks
                $num_chunks = 1;
                $chunk_size = $metadata['filesize'];

                if ($metadata['filesize'] > $max_chunk_size) {
                    $num_chunks = ceil($max_part_size / $max_chunk_size);
                    $chunk_size = $max_chunk_size;
                }

                while ($num_chunks > 0) {
                    array_push($chunks, [
                        'offset'        => $chunk_offset,
                        'seek_point'    => $seek_point,
                        'size'          => $chunk_size,
                    ]);

                    $chunk_offset += $max_chunk_size;
                    $seek_point += $max_chunk_size;
                    if ($seek_point >= $metadata['filesize']) {
                        break;
                    }

                    $num_chunks--;
                }
            }
            else {
                // 1 part = 1 chunk
                array_push($chunks, [
                    'offset'        => 0,
                    'seek_point'    => $seek_point,
                    'size'          => $max_part_size
                ]);
                $seek_point += $max_part_size;
            }

            array_push($parts, [
                'api_key'       => $api_key,
                'part_num'      => $i + 1,
                'uri'           => $upload_data['uri'],
                'region'        => $upload_data['region'],
                'upload_id'     => $upload_data['upload_id'],
                'filepath'      => $metadata['filepath'],
                'filename'      => $metadata['filename'],
                'filesize'      => $metadata['filesize'],
                'mimetype'      => $metadata['mimetype'],
                'location'      => $metadata['location'],
                'chunks'        => $chunks
            ]);
        }

        return $parts;
    }