vincent15000's avatar

How to copy a file from local to the cloud

Hello,

I have this upload URI given by the Adobe PDF API (I have replaced the token and other data in the URL by fake strings).

https://dcplatformstorageservice-prod-eu-west-1.s3.amazonaws.com/xxxxxxxxxxxxxxxxxxxxxxxx%40techacct.adobe.com/xxxxxxxxxxxxxxxxxxxxxxxx?X-Amz-Security-Token=xxxxxxxxxxxxxxxxxxxxxxxx-Signature=xxxxxxxxxxxxxxxxxxxxxxxx

I need to upload a file from the local webserver to this address.

How is it possible to do that ?

It's probably very simple, but I really don't get it work.

Thanks for your help.

V

0 likes
9 replies
vincent15000's avatar

@jlrdw I test from my local webserver, it's not HTTPS (php artisan serve), but the app in production is HTTPS.

jlrdw's avatar

@vincent15000 Adobe has this:

Only HTTPS based signed URIs are supported.

Edit:

I would double check with client and make sure the pdf files need merged. You could suggest just zip instead of merge.

I.e., They have 5 to combine, just zip the 5 together.

It sure would make things easier. But just suggestions.

1 like
vincent15000's avatar

@jlrdw To be sure ...

The presigned URI IS HTTPS, it's the URI for the AWS cloud for Adobe to upload a PDF file (and then merge it with another and then retrieve the merged file).

So what you are saying is that the source has also to be HTTPS ?

But when I try to send the file to the cloud, I don't send the source URL of the file, I attach the file to the post request.

$response = Http::attach(
    'attachment', file_get_contents('photo.jpg'), 'photo.jpg'
)->post('http://example.com/attachments');

https://laravel.com/docs/10.x/http-client#multi-part-requests

So what you say is that even in this situation the source webserver has also to be HTTPS to be able to send the request to Adobe ?

jlrdw's avatar

@vincent15000

So what you are saying is that the source has also to be HTTPS ?

I am not sure. Try sending from https if possible.

1 like
vincent15000's avatar

@jlrdw I have tried sending from HTTPS and it doesn't work better, I get a 403 error yet.

I have tried with a POST and a PUT request, both give me the same result.

vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

@jlrdw It works without HTTPS on the local side.

I just have to send the file inside the body and not attached to the request.

And with AWS presigned URL, it's necessary to send a PUT request and not a POST request. This wasn't mentioned in the documentation.

$response = Http::withBody(
    file_get_contents($file_path), 'application/pdf'
)->put($upload_uri);

Please or to participate in this conversation.