sdk-for-php icon indicating copy to clipboard operation
sdk-for-php copied to clipboard

📚 Documentation: update file with content

Open jenniestrongbow opened this issue 3 years ago • 8 comments
trafficstars

💭 Description

Hi, after reading your documentation, I could not figure out how to update a file I created earlier with new content. Please help. Thanks

👀 Have you spent some time to check if this issue has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

jenniestrongbow avatar Dec 19 '21 08:12 jenniestrongbow

You can only update the file permissions like this:

<?php

use Appwrite\Client;
use Appwrite\Services\Storage;

$client = new Client();

$client
    ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    ->setProject('5df5acd0d48c2') // Your project ID
    ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;

$storage = new Storage($client);

$result = $storage->updateFile('[FILE_ID]', [], []);

For what you're trying to achieve, you have to delete the old file, and create a new one.

eldadfux avatar Dec 20 '21 08:12 eldadfux

More info is available here: https://appwrite.io/docs/server/storage?sdk=php-default#storageUpdateFile

eldadfux avatar Dec 20 '21 08:12 eldadfux

Ok, thanks, I saw that page. But It din't make sense to me as you can't upload a file to the file with the same ID.

jenniestrongbow avatar Dec 30 '21 19:12 jenniestrongbow

I saw in your example that you entered https://[HOSTNAME_OR_IP]/v1. How do I get https to work with my IP? Should I install certbot? In my experience, it only works with Apache? Which I don't want to use as my 80/443 ports are used by my appwrite. Thanks

jenniestrongbow avatar Dec 30 '21 22:12 jenniestrongbow

Ok, thanks, I saw that page. But It didn't make sense to me as you can't upload a file to the file with the same ID.

That is true, the ID will be different. You will have to update your database and set the new ID there. In future, we plan to support Custom IDs that will allow you to set anything as an ID - this will allow you to create a new file with the same ID.

Meldiron avatar Dec 31 '21 11:12 Meldiron

I saw in your example that you entered https://[HOSTNAME_OR_IP]/v1. How do I get https to work with my IP? Should I install certbot? In my experience, it only works with Apache? Which I don't want to use as my 80/443 ports are used by my appwrite. Thanks

You could generate custom certificates for your IP address manually (self-signed), but I am not sure how secure that is - browsers might still complain. I recommend you get a domain and set up HTTPS on the domain name.

Let's Encrypt (tool Appwrite uses) issues domain-validated certificates. The certificates must be attached to at least a domain name.

Meldiron avatar Dec 31 '21 11:12 Meldiron

Hi meldiron, thanks for your feedback. I upgraded to version 0.12, so I'll test and see if we can now use custom IDs.

Re. HTTPS, I used Let's Encrypt with a specific domain. Thanks

kiloki-official avatar Jan 07 '22 21:01 kiloki-official

@Meldiron is this still relevant? If not please close this.

lohanidamodar avatar Feb 11 '22 06:02 lohanidamodar