To create a post on linkedin with an asset, we need to first request an uploadUrl which looks something like this: https://www.linkedin.com/dms-uploads/C5610AQFBWK_SJ1Cexw/uploaded-image/0?ca=vector_ads&cn=uploads&sync=0&v=beta&ut=0_UB6ruLt7nqw1
Is there any way I can upload an image in s3 bucket directly to this url in my backend?
I have tried using HTTP PUT and POST with --from header and content type image/png and the response in 201 created but the linkedin image API says processing failed.
Related
I have a webapp and each user can upload images to a private AWS S3 bucket.
In the desired page each user can view his images. Unlike other files (text / csv files etc...), these images should be displayed immediately when the page loads and not downloaded to the local computer one by one.
To display the relevant images to the user I found few ways:
Download the images in the server directly and send them as HTTP response to the user.
Use presigned URLs and if the image is expired a request will be sent to refresh the presigned URL from the server. The new URL will be sent to the user and will be saved in the DB as well that the next time a user requests for the image he has the updated presigned URL.
The first approach is not ideal.
The second approach sounds more efficient, but let's assume a page contains dozens of images that should be displayed and all the presigned URLs have expired. Should I take this approach altough it might end with dozens of requests just for refreshing the presigned URLs? As far as I know it is a problem because there isn't an option the generate presigned URL without expiry (7 days max) and there isn't an option for generating presigned URL for entire directory instead of an object. And what happens to browser caching when presigned URLs are refreshed?
I am wondering what is the best approach for displaying the private images that cannot be shared between users.
Any suggenstions?
Thanks.
So prior to switching to AWS S3. I was using Gallery saver (https://pub.dev/packages/gallery_saver)
I switched to hosting media files on AWS S3 (with django as my back end) and was trying to download an image. I pass in the URL(signed URL) that points to the media file in my aws s3 bucket and now its not downloading the image and saving it to the gallery.
this is what I was using before, no code has changed:
await GallerySaver.saveImage(url);
is there any other way to save images from a url link to an AWS S3 object to your gallery in flutter. Am I doing something wrong?
The image it self loads perfectly in flutter using CachedNetworkImage so I know the URL works and when I click the url in the browser, I'm able to access/download the image.
I realized the error is : OS Error: File name too long, errno = 36)
so long URL is causing this
I am using s3-bucket to store app config data for multi tenant application. I need tenant info saved in public file(.json) in s3-bucket before client is logged in to the application. For example, app config data might be client logo and some custom title/sub-title for each tenant and etc. I am trying to fetch file content based on sub-domain.
So, I need to fetch the client data, while rendering the login component itself. I am using aws-sdk tool in client side, but am facing 'missing credentials` error.
I am not getting, How to achieve this??
thanks and regards
SHASHIDHAR N K
The AWS SDK for Javascript uses the S3 rest API in such a way that it requires a GET request to be authorized. This is because it uses request parameters to override response header values and for these the rest API documentation for GET says:
Note - You must sign the request, either using an Authorization header or a pre-signed URL, when using these parameters. They cannot be used with an unsigned (anonymous) request.
However, you don't need to use S3 to get a public file, you can make a standard http request using XMLHttpRequest or suchlike.
I am building an app which lets users upload pictures and share it with his/her friends only.
I am using spring restful services to upload content directly to s3.
The user is authorized using OAuth.
To upload an image an authorized user's js client invokes POST /images/{userid}
To download the image, the client has to invoke GET /images/{userid}/{imageid}
Each user's content is stored in s3 under his own folder name, and the downloading service as explained in point 4 is the one that has to be invoked. Unfortunately, this means I cannot assign this url as source to an image tag <img src="">, because the authorization token should be sent on GET request. I cannot make the contents of user folder public because only user and his friends are allowed to see the images. The current service will soon become a bottleneck and I would like to avoid that.
What is the recommended architecture/design to solve this problem?
Instead of having a service that loads and returns the entire image file from S3, you should have a service that simply generates an S3 presigned URL. Then the URL retrieved from that service can be used in the <img src=""> tags on your site. This will be much more performant since the web browser will ultimately download the image directly from S3, while also still being secure.
The flow for downloading the images would be like this
User invokes GET request to download image
At Server End
Authenticate user
Query DB for metadata
Create a time based auth token.
Create a image URL(S3 based) and append auth token created in previous step
At the client end(User browser) redirect user to new URL(this url is effectively S3 location+auth token )
Now direct request will comes at the server( image URL+ auth token)
authenticate the token and then show image to user
Above URL will not be valid for long time , but your images are secured. As auth token is time based it will cater your case like if some one make the image private/public remove a friend.Deleted images , Copy paste of image url etc ..
I've got a Django Rest API and a React Native app. I'd like to upload some files to my s3 bucket from my app.
I could do this :
User would like to upload an image --> GET my_api/s3/credentials/
App --> POST image directly to s3 using credentials (access/private keys)
The problem is that once the user has the accessKey and privateKey, he can use it indefinitely.
Is there a way to retrieve temporary credentials I could give to the user after a call on my_api/s3/credentials/ ?
I've found an answer. It is possible to generate from server side a temporary URL to POST your content.
details here