Google 一次为多个对象创建签名 url 的存储

Google Storage creating signed url for multiple objects at once

我已经成功地为 google 存储中的图像和视频内容使用了签名 url。我的 Django Apis return 100 Google 存储对象和创建 100 个签名 url 确实需要很长时间。有没有其他方法可以更快地生成签名网址或一次生成多个签名网址?

class FileUploadSignedURL(APIView):
@method_decorator(login_required(login_url='/login/'))
def post(self, request):
    filename = request.POST.get('filename')
    filetype = request.POST.get('type')
    filesize = request.POST.get('size', 0)

    uuid = get_random_string(11)
    path =  '{0}-{1}/{2}/'.format(request.user, request.user.id, uuid)
    logging.info(path);

    video = Video.objects.create(title=filename,
                                 uuid=uuid,
                                 path=path,
                                 user=request.user,
                                 type=filetype,
                                 size=filesize,
                                 status="signed")
    # create the blob - the blob has to be created in order to get a signed URL
    full_path = '{0}{1}'.format(video.path, video.name)
    blob = default_storage.open(full_path, 'wb')

    signed_url = blob.blob.generate_signed_url(expiration=default_storage.expiration, method='PUT', content_type=filetype)
    logging.debug(signed_url);

    logging.debug("FileUploadSignedURL(APIView) end")
    return Response({"uuid":video.uuid, "title": video.title, "signed_url":signed_url})

我的建议是将性能与基本示例进行比较:

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/storage/cloud-client/storage_generate_signed_url_v4.py

您能否为此创建一个新的服务帐户?