I am uploading images to dropbox via the API call seen here:
var promise_uploadDropbox = xhr('https://content.dropboxapi.com/1/files_put/auto/Screenshot.png?overwrite=false', {
aMethod: 'PUT',
Headers: {
Authorization: 'Bearer ' + gEditor.dropboxOauth.access_token,
'Content-Type': myBlob.type,
'Content-Length': myBlob.size
},
aPostData: myBlob,
aResponseType: 'json'
});
I save in history the response.path for future, so I can delete this image, however if the user renames the image on the dropbox web app, then this delete operation will fail. Is there a way to find an image by a given rev or other identification, as this is supplied in the response object of the api call above.
Backstory for this need
I have created a Firefox addon. In this addon users take a screenshot and then edit/crop it, then save it, after the save is complete I copy to the clipboard the file or http path to the image so they can use in forums in galleries, etc etc etc (aside: perm img link important). People like the option of cloud storage so I am brining Dropbox.
I keep a history of the users actions in a HTLM5 application, form this dashboard, I give users a quick way to copy image link, or delete from server the file. (aside: another point where a perm link to the image is important as its an offline app, and I show the image in the )`
Here is a image of my dashboard:
The upcoming Dropbox API v2 (currently in preview) has a concept of IDs for files, and you will indeed be able to delete by file ID in API v2.
But for API v1 (the current version), no such ID exists.
EDIT: I thought deleting by file ID already worked in API v2, but it turns out it doesn't! It will by v2 release, though.
Related
I am trying to update the token metadata for my existing token. Is there any other steps needed to be carried out to update the token metadata correctly?
I have updated the token metadata by using Strata Protocol Token Launchpad (https://app.strataprotocol.com/edit-metadata) 1 week before. But it didn't reflect on the token logo and name at all on the Solana Explorer.
Token Address: https://explorer.solana.com/address/7KG5WNqNbUdXY5MBX7TUVZMTSD5cGoYxwYwry96GD1sM/metadata
How can I update token name and logo correctly?
How can I edit or remove the social channels link with metadata?
Any help is appreciated as always. Thanks in advance.
The new standard to SPL token metadata is actually that the same of NFT's now.
Each token will have it's own token metadata account (which will need creating if token was created via the SPL Token CLI), in your case once was created for you if you used Strata to create the token.
Updating the SPL token metadata is now as simple as updating an NFT on Solana. Various tools such as https://metaboss.rs is one, Strata website should also work to update the token tool. I've also got a site which after testing updates tokens too just fine but at the moment adds in some unessaccery data related to NFT's, but functions. If you wish to try that let me know in a comment.
If Strata doesn't work for you you could try Metaboss.
You'll need to first upload an image and a JSON file to arweave that you would then link to each other.
Upload Image to Arweave or similar.
Create and upload a new json file (to arweave or similar) with a few attributes inside it.
https://github.com/solana-labs/token-list
You can see from the above document at Solana Labs that you need
{
"name": "TOKEN_NAME",
"symbol": "TOKEN_SYMBOL",
"description": "TOKEN_DESC",
"image": "TOKEN_IMAGE_URL"
}
in your JSON file. Your image URI should be a link to the image you uploaded in step one.
You can then use the update commands at metaboss to upload some onChain details such as name, symbol, and the URI.
https://metaboss.rs/update.html
Hmm got same problem here,
In my case, I setAuthority of the SPL token to null right after initiate and mint to make sure no one could ever mint more.
What they said "You must have mint authority in order to create or update the metadata", mean that existing spl-token have no way to update their metadata.
When I browse a GitHub repo, I can copy the URL from the browser, and I can share it like this -
https://github.com/zlatko-michailov/onesql/blob/master/lang/src/onesql.syntax.ts. The file content is returned in the http response stream without any decorations.
How can I do the same thing for a VSO repo? If I have to tweak the URL a little bit, that's OK.
I see the browser uses a REST API that is documented here - https://learn.microsoft.com/en-us/rest/api/azure/devops/git/items/get?view=azure-devops-rest-5.0. I played with different combinations of includeContent, $format, download, etc., but I could only get the content as a separate download, not in the http response body.
The subject file is some CSV data, and the client is Excel, which doesn't seem to be able to handle downloads.
I solved my own problem. There is no need to create a feed.
The API that fetches raw files is sourceProviders. The link is here: https://learn.microsoft.com/en-us/rest/api/azure/devops/build/source%20providers/get%20file%20contents?view=azure-devops-rest-5.0
It is not very well documented - examples for the required parameters are missing. The tricky one is sourceProvider. It has to be tfsgit. Skipping serviceEndpointId worked for me.
Here is the pattern:
GET https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/tfsgit/filecontents?&repository={repository}&commitOrBranch={commitOrBranch}&path={path}&api-version=5.0-preview.1
I'm helping maintain an app that integrates with Facebook, and has lots of archived links to old private message images. Sometimes these images expire, and we go to facebook and request a new image. This works 90% of the time.
About 10% of the time we're getting back a response that we can't tell what the new image is.
What's the proper way to request a new url for an expired Facebook Private Message image, preferably using v2.5 or newer of the Graph API?
Currently we're doing a GET request to Facebook's Graph API using the message id of the private message like so:
https://graph.facebook.com/v2.3/m_mid.XXXXXXXXX:YYYYYYYYY
and that gives us a response that has a bunch of attachments in it. For 90% of use cases, there's a new attachment that has an url or name field with a new filename that contains the old filename, e.g. old file name being XXX, we'd see a new filename like ....XXXX.... in the url field.
attachments [url='*%s*']/image_data/url
attachments [name='*%s*']/image_data/url
or sometimes
picture
but that doesnt match what we get now, which is a bunch of attachments with no way to map to the new image.
We haven't been able to find a graph API way of doing this, but have the following solutions we're considering:
When there's only one attachment in the response, we just use that one url. This works some of the time, but fails when there's more than one image of course
Save more metadata about the image, at worst case an MD5 of the file. Then compare that to MD5's of the other files until we get the one we want. Instead of an MD5, we could consider using info about the file from a HEAD request. All of this is untested.
Update our old message metadata with new metadata whenever this happens, thus avoiding the problem entirely as new image requests would come from the new metadata.
i would like to ask, if there's any way to retrieve files links of folder which is publicly shared. Like someone create random public folder(everyone can view it) and put some random files into it. So i need to get all files links from that folder. All i know is link to that folder in format: https://www.dropbox.com/sh/[code]/[code].
Can i do that by using dropbox api, or the only option is to scrape dropbox page directly?
Here is a copy paste example:
using Dropbox.Api;
using Dropbox.Api.Files;
...
// AccessToken - get it from app console
// FolderToDownload - https://www.dropbox.com/sh/{unicorn_string}?dl=0
using (var dbx = new DropboxClient(_dropboxSettings.AccessToken))
{
var sharedLink = new SharedLink(_dropboxSettings.FolderToDownload);
var sharedFiles = await dbx.Files.ListFolderAsync(path: "", sharedLink: sharedLink);
foreach (var file in sharedFiles.Entries)
{
}
}
The documentation wasn't clear about setting path to an empty string when using it with publicly shared folders.
The official way to get information about a particular shared link is to use the Dropbox API's /2/sharing/get_shared_link_metadata endpoint:
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata
In the official Dropbox .NET SDK that's the GetSharedLinkMetadataAsync method:
https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Sharing_Routes_SharingUserRoutes_GetSharedLinkMetadataAsync_1.htm
This unfortunately doesn't offer the list of files though. We'll consider that a feature request.
Note that scraping the site would be error prone and likely to break without warning. (It's also against the terms anyway.)
Edit:
Dropbox API v2 now supports listing the contents of a shared link for a folder. This can be accomplished using the same interface as listing a folder in a connected user's account, via the list_folder functionality. To list the contents of a shared link for a folder, you instead provide the shared link URL in the shared_link parameter to /2/files/list_folder:
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
If you're using an official SDK, there will also be a corresponding method for this endpoint. In the .NET SDK that's available as ListFolderAsync:
https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_ListFolderAsync_1.htm
I'm trying to integrate my rails app with SugarCRM. Is it possible to fetch the Contact picture from SugarCRM using REST API? Please let me know.
To get the profile image for a user do the following:
Call the login method through REST
Call the get_entry_list method through REST, with the following parameters:
Module: Users
Query: users.user_name = 'xxxx'
Select_fields: picture
The response contains the filename for the profile image, which is stored in /uploads.
However, it is not possible to view the image in that folder due to .htaccess restrictions for security reasons, but other options exist:
Extend the REST API with a method to serve profile images (similar to get_document_revision)
Login on the server from your rails app and get the image
Create a simple entrypoint+module in SugarCRM, which can show the picture
Remove the .htaccess restiction for images (if it doesn't create a security risk in your setup)
In such scenario, I faced a problem where the upload folder stores file with name of the record id, i.e the GUID without file extension.
So to cop up with this I did write a function to copy the file at same hierarchy but with its extension.
Example:
A png extension file at upload folder with name say, '32sdft-tg35f-Tuhis-675rtyf-77666-46dgc' will end up as, '32sdft-tg35f-Tuhis-675rtyf-77666-46dgc.png'
Now only the path will be require to render the image.
Rest all things as applicable as suggested by our friend, Kare !!