Is it possible to use a file path instead of url as `image_url` when sending a message via Slack API or Incoming Webhook? - image

Let's assume I have the following block which I want to send via Incoming Webhook to Slack
{
"type": "image",
"title": {
"type": "plain_text",
"text": "foo bar"
},
"image_url": "https://api.slack.com/img/blocks/example/beagle.png",
"alt_text": "foo"
}
but instead of providing a http url as image_url I would like to provide a file path because the file I want to send is in the same folder as my script.
1) Is this possible? I guess no.
2) Is it possible to upload an image via files.upload in a first step WITHOUT actually displaying is on any channel just to get the URL which then can be used as image_url?

1) No. As I mentioned earlier its not possible to use a file path to directly include an image in a message. The only way is to provide a public URL to an image file.
2) Yes, you can use files.upload you uploaded to Slack in your messages. And you do not have to share them in any channel do it.
The basic approach is:
Upload your image to Slack with files.upload. And if you do not provide any channels with that API call the file will not be shared in any channel. You will get the file object incl. the file ID of the uploaded image file.
Call files.sharedPublicURL to make that file public by providing the file ID
Your image file is now public and you can use the permalink_public of the file object to include that image in message. However, you still need to construct the direct URL for that image from the URL you get from permalink_public. Check out this post on how to get the direct URL for the image.

Related

How can I save an image via API in Laravel Server from React Native

I am trying to save some info and an image sent through api from React Native app. This is the request that I get if I log it.
[2022-08-05 10:11:09] local.ERROR: array ('{
"data":{
"_parts":' => array ('[
"image", {
"modificationDate":"1659694264000","size":2883040,"mime":"image/jpeg","height":4160,"width":3120,"path":"file:///storage/emulated/0/Android/data/com.wheeloffortune/files/Pictures/image-6ab1ad33-2580-416b-be7d-09a0662739218182247041115654861.jpg"
}' => NULL,
),)
When I tested api from postman I get image as a file and have saved it easily without a sweat. But from the app the developer sends in the format I pasted above. Can I somehow save image from the above request.

Full Media URL in Strapi

The Strapi API responds the media URLs as something like "url:'/uploads/thumbnail.png'".
I would like to get the complete URL that links to my file as value for "url". For example: "url:'https://example.org/uploads/thumbnail.png'"
The documentation also shows the full URL as response. How can I achieve this?
The full URLs come from using an upload provider such as AWS-S3 or Cloudinary. The local provider doesn't support full URLs at the moment.
There are some potentials reasons why you shouldn’t store a full URL, and respond with a full URL. I won’t dive into those reasons.
I suggest creating the entire request/response, or creating a middleware component to intercept the response.
Then you can modify the original url value with the site’s URL. Looping through the results with something like:
const serverHost = strapi.config.get('server.host', 'defaultValueIfUndefined');
url = serverHost + url;
See the following docs for more details:
https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations.html
https://docs.strapi.io/developer-docs/latest/development/backend-customization/middlewares.html#implementation

Destroy image from cloudinary

when I delete the image from my graphql server and using uploader.upload.destroy(public_id), it deletes from media library of cloudinary (https://cloudinary.com/console/media_library/folders/%2F)
but image is still available If I access it via cloudinary endpoint (https://res.cloudinary.com/db9rcrnuw/image/upload/v1576054005/47122.png)
I want to destroy those endpoints as well when the image is deleted.
here, screen.basePath means public_Id of the image
const screen = await ctx.prisma
.deleteScreen({
id: args.screenId
})
.$fragment(fragment);
if (scrn.basePath.length === 5) {
console.log(scrn.basePath.length);
cloudinary.uploader.destroy(screen.basePath, function(error, result) {
console.log(result, error);
});
return screen;
}
The short answer is that this is caused by a combination of not using the 'invalidate' parameter in your destroy API call and a difference between which URL format (i.e. with a version number (v123456789), 'v1' or no version number) the resource is accessed using versus what format your account is configured to send for invalidation.
The first thing to do is ensure that all destroy API calls include the 'invalidate' parameter set to 'true' if you'd like CDN invalidation.
Regarding the URL formats;
The 'v1576054005' that is part of delivery URLs is a version number that is essentially the UNIX timestamp of the upload time of the asset. Its main purpose is to always return the latest image and avoid CDN caching (upload API responses return the URL with the latest upload version). A bit more information on this topic can be found in this article - https://support.cloudinary.com/hc/en-us/articles/202520912-What-are-image-versions.
Please note that there are three possible URL formats Cloudinary can send for invalidation at the CDN, and these are outlined here: https://support.cloudinary.com/hc/en-us/articles/360001208732-What-URL-conventions-are-invalidated
Invalidation requests are sent when you delete or overwrite an image using the Media Library UI, or when you use the SDK/API, and also provide the 'invalidate' parameter, set to 'true'.
By default, all accounts send invalidations for the default format of URL which the SDKs produces, which uses no version number for assets in the root of your account, and a 'v1' placeholder for assets in folders (option 1 from the URL above).
If you were accessing the image with the full version component then that isn't sent for invalidation by default and why you are likely getting a cached copy returned.
In your case, the URL that would've been sent for invalidation would be without a version component (as the resource is in the root folder) i.e.
https://res.cloudinary.com/db9rcrnuw/image/upload/47122.png
Depending on how you are building your URLs, i.e., if you're using the SDK helper methods, taking the URL from the url or secure_url fields of the Upload API response (which use the full version number), will determine the format and thus how your account should be configured to invalidate.
I suggest you to email Cloudinary support (support#cloudinary.com) and share a link to this thread as well as some details on how the URLs you're using are generated so that your account can be configured accordingly.

How to send custom form data to FineUploader Azure Success endpoint?

I am using FineUploader 5.13.0 with the Azure Blob Storage end point.
I have it successfully uploading files directly to blob storage, and also successfully hitting my web server success endpoint when the upload is concluded.
However, I am looking for a way to include custom data in the post to the success endpoint.
This bit in the documentation seems to imply that it is possible.
Under the section "Optional server-side tasks" for "uploadSuccess.endpoint", it says it will send
"Any parameters/form fields you have associated with the file".
However, I just cannot seem to figure out how to do that.
This issue seems to refer to it, but doesn't give enough info.
https://github.com/FineUploader/fine-uploader/issues/1313
Note, I am not referring to the feature to hook into existing HTML forms as explained on this documentation page:
"Integrating with Existing HTML Forms"
https://docs.fineuploader.com/branch/master/features/forms.html
You might be looking for FineUploader's Request params. This allows you to add extra form data.
Eg:
new qq.FineUploader({
// elided
request: {
params: {
testing: "THIS IS A TEST"
}
}
});
This will show up in the multi-part body of the request:

How to use uploading dropped and pasted images using CKeditor

I want to implement following using fuelPHP.
http://ckeditor.com/tmp/4.5.0-beta/image-upload.html
Then, I added all plugins and can upload the images to my directory.
However, I do know the format of the response for client side of CKEditor and so CKEditor is not able to locate file path.
Dose anyone know the format of its response?
I return the json object like following.
json_encode(array('responseText'=>'ok','uploaded'=>1,'fileName'=>"/assets/img/upload/d2ceb4f415e252199483ee96f5ba361d.png"),true);
The response should be like following
{
"uploaded": 1,
"fileName": "foo.jpg",
"url": "/files/foo.jpg"
}

Resources