Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 以html格式显示AWS BOTO上载状态_Django_Angularjs_Amazon Web Services_Amazon S3 - Fatal编程技术网

Django 以html格式显示AWS BOTO上载状态

Django 以html格式显示AWS BOTO上载状态,django,angularjs,amazon-web-services,amazon-s3,Django,Angularjs,Amazon Web Services,Amazon S3,我使用Django和Angular js。我使用BOTO将照片上传到s3上。如何使用django获取上传状态并使用angular js显示 我有以下功能: def percent_cb(complete, total): print '%d bytes transferred out of %d' % (complete, total) def upload_to_s3(project_file): sourceDir = photos_folder + project_fi

我使用Django和Angular js。我使用BOTO将照片上传到s3上。如何使用django获取上传状态并使用angular js显示

我有以下功能:

def percent_cb(complete, total):
    print '%d bytes transferred out of %d' % (complete, total)


def upload_to_s3(project_file):
    sourceDir = photos_folder + project_file +'/'
    destDir = '/photos/'+ project_file +'/'
    MAX_SIZE = 20 * 1000 * 1000
    PART_SIZE = 6 * 1000 * 1000

    conn = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_SECRET)
    bucket = conn.get_bucket(bucket_name)

    k = boto.s3.key.Key(bucket)
    k.key = destpat
    k.set_contents_from_filename(sourcepath, cb=percent_cb, num_cb=10)
以下是我上传示例照片时的日志:

0 bytes transferred out of 508450
57344 bytes transferred out of 508450
114688 bytes transferred out of 508450
172032 bytes transferred out of 508450
229376 bytes transferred out of 508450
286720 bytes transferred out of 508450
344064 bytes transferred out of 508450
401408 bytes transferred out of 508450
458752 bytes transferred out of 508450
508450 bytes transferred out of 508450
我想在每次打印时获得百分比_cb的输出,并将其传递给angular以用于html显示

他们有办法做到这一点吗

  • 谢谢